How to use the pdb debugger on a python script
So your script/program/code is not working and nobody is around to help you! The pdb debugger can assist you.
First identify what line number is having the issue (or approximate area)
Run the pdb debugger with the command: pdb script_name args
Verify that pdb is where you want to be with the line number or code area
If you are in the area you wish to be, you can just [c]ontinue to make your way through the code
Here are some common commands you can use in pdb:
(b)reak - set break points
(cl)ear num - delete break point
(cl)ear - delete all break points
[c]ontinue - continue execution
disable - disable break points
(h)elp - help
(h)elp command - to get command help
(l)ist - show code around current line
(n)ext - next line
restart re-read script and restart debugging
(s)tep - step into scope
note: after you do a command (i.e. (n)ext), hitting enter will repeat the command again
Here is a nice quick introduction to the pdb tool:
For those that learn better reading, here is a good website with a text description:
Click to go back to the Programming Main Page