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

27.1. Starting up pdb

To execute any Python statement under the control of pdb:

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

where yourModule.py contains the source code you want to debug.

To debug a Python script named myscript.py:

python /usr/lib/python2.5/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.