How to use pdb?

tron.thomas at verizon.net tron.thomas at verizon.net
Fri Jul 21 00:46:07 EDT 2006


I am trying to figure out how to use the pdb module to debug Python
programs, and I'm having difficulties.  I am pretty familiar with GDB
which seems to be similar, however I cannot even get the Python
debugger to break into a program so I can step through it.  I wrote a
simple program and below is an example of the steps I tried, as well as
the results I got:

>>> import pdb
>>> import MyProgram
>>> pdb.run('MyProgram.mainFunction')
> <string>(1)?()
(Pdb) b MyProgram.MyClass.method
Breakpoint 1 at MyProgram.py:8
(Pdb) cont
>>>

The program should have printed a message to the screen when execution
was continued, and it should have hit the breakpoint during that
execution.  Instead the debugger exitted to the main prompt.

What is the reason the dubugger behaves like this?
What is the correct way to accomplish what I am trying to do?

I have tried this process on Python 2.3.5 and 2.4.3 with the same
results on each version.




More information about the Python-list mailing list