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).
To execute any Python statement under the control of
pdb:
>>> import pdb
>>> import yourModule
>>> pdb.run('yourModule.test()') # Or any other statementwhere yourModule.py contains
the source code you want to debug.
To debug a Python script named
myscript.py:
python /usr/lib/python2.2/pdb.py myscript.py
To perform post-mortem analysis:
>>> import pdb >>> import yourModule >>> yourModule.test() [crash traceback appears here] >>> pdb.pm() (pdb)
Then you can type debugger commands at the
(pdb) prompt.