The Debugger
PythonWin also has a built-in Python debugger to help you develop your scripts. The PythonWin debugger includes all the features you expect in debuggers, including:
Breakpoints that can be set at any location. Optionally, these breakpoints may have a condition that must evaluate to
true
before the breakpoint stops.A watch window allowing easy tracking of changes to key variables.
Commands allowing you to step into, over, or out of functions.
If you are familiar with other Windows IDE debugging environments (such as Visual C++, Visual Basic, or Delphi) you should find the debugger easy to work with.
For a language as flexible as Python, there is one huge limitation in the debugger that is worth noting. It isn’t possible to modify the code while it’s being debugged. If you spot a bug while debugging, code changes you make aren’t applied until you reload the module. Further, any source-code changes are likely to disrupt the debugging session, as the debugger will still be stepping though the original line positions even though they are likely to have changed.
The simplest way to use the debugger is to run scripts using the same technique described earlier, but this time select one of the debugging options. The Run Script dialog provides the following debugging options:
- No debugging
This means that the script runs normally without any debugging; it doesn’t stop at breakpoints.
- Step through in the debugger
Steps through each line in the debugger. Selecting this option invokes ...
Get Python Programming On Win32 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.