O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Debugger

As you expect of an IDE, IDLE contains a built-in debugger. To use the debugger, it must first be enabled via the Debug Debugger command from the Python shell window. The debugger dialog appears, and the shell window responds with:

[DEBUG ON]
>>>

IDLE is now ready to debug. To start the debugger, open the script to debug and run (or import) it. For the purposes of this example, let’s debug the same script you used for PythonWin (C:\Scripts\pywindemo.py in the example). Once the file is open, select Edit Run script (or press Ctrl-F5). The debugger dialog becomes active, and the debugging session begins. Figure 4.7 shows you stopped inside your main function.

IDLE’s debugger
Figure 4.7. IDLE’s debugger

The stack leading to the current call is shown. Selecting an entry displays the local and global variables and the source code for the stack entry, depending on the options selected at the top of the dialog.

At the time of writing, there are a few limitations in the IDLE debugger worth mentioning:

  • When debugging the top-level of a module, the Go and Over commands function like the Step command. Go and Over don’t function correctly until the top-level script calls a function.

  • The Python shell window is effectively disabled during the debugging session. You can’t use normal Python commands to view and change variables while the debugger is active.

It’s quite possible that these and other limitations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required