Traceback Detective¶
Run the Traceback Detective MicroSim Fullscreen
You can include this MicroSim on your website using the following iframe:
<iframe src="https://dmccreary.github.io/robot-arm/sims/traceback-detective/main.html"
height="624px" width="100%" scrolling="no"></iframe>
Description¶
Read five real Python tracebacks. For each one, click the line that names the error type, then click the frame you would check first, and see why. Used in Chapter 1.
Each traceback is drawn line by line in a white box. Moving the pointer over the box shades the line, or the whole frame, that a click would choose. A frame is a line starting File together with the code under it.
The project folder in every traceback is /home/maker/arm-lab/. Frames in files under /usr/lib/python3.13/ belong to Python's own library. Tracebacks 1 to 4 came from running short scripts under Python 3.13, with the real folder names replaced. Traceback 5 is the standard report for a failed import.
Lesson Plan¶
Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.
- Find the error line. Click the line that names the error type and press Check. The correct line turns green.
- Find the frame. Click the frame you would check first and press Check. Use the rule from the chapter: the deepest frame whose file is inside your own project folder.
- Read the reason. The feedback explains what went wrong in the program and where to look.
- Repeat for all five tracebacks. That makes ten answers. Mastery is 8 of 10.
- Think about it. Traceback 3 is the longest, but your own code appears in only one frame. Does a longer traceback mean a harder bug?
Specification¶
The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 1: Setting Up Python for Robotics.
References¶
- Errors and Exceptions - The Python Tutorial - How Python reports an uncaught exception and what the last line of the report means.
- traceback: Print or retrieve a stack traceback - Python Standard Library documentation - The format of a traceback, frame by frame.