Friday, September 16th, 2005
Useful Commands for Python Debugging
As explained in the Python Library Reference
documentation,
command-line debugging in python is made possible by the pdb module.
I like using it this way:
python -m pdb myscript.py
Once you’re in the debugger, the following commands were most useful.
h(elp): show me some help
w(here): print the current stack trace (where is the code now?)
u(p)andd(own): navigate up/down within the stack heirarchy
s(tep): run current line of code, stopping within sub-functions
n(ext): run current line of code, stopping at next line in the current function (aka step over)
b(reak): specify a breakpoint
c(ont(inue)): run until you hit a breakpoint
l(ist): show the source code surrounding the current line
p <expression>: print the contents of an object <expression>
q(uit): quit the debugger and your program
