Next / Previous / Contents / TCC Help System / NM Tech homepage

19. The Python debugger

The Python debugger allows you to monitor and control execution of a Python program, to examine the values of variables during execution, and to examine the state of a program after abnormal termination (post-mortem analysis).

19.1. Starting up pdb

To execute any Python statement under the control of pdb:

>>> import pdb
>>> import yourModule
>>>'yourModule.test()')  # Or any other statement

where contains the source code you want to debug.

To debug a Python script named

python /usr/lib/python2.2/

To perform post-mortem analysis:

>>> import pdb
>>> import yourModule
>>> yourModule.test()
[crash traceback appears here]

Then you can type debugger commands at the (pdb) prompt.