Python debugging tips
debugging, python
Solution
PDB
You can use the pdb module, insert `pdb.set_trace()` anywhere and it will function as a breakpoint.
>>> import pdb
>>> a="a string"
>>> pdb.set_trace()
--Return--
> <stdin>(1)<module>()->None
(Pdb) p a
'a string'
(Pdb)
To continue execution use `c` (or `cont` or `continue`).
It is possible to execute arbitrary Python expressions using pdb. For example, if you find a mistake, you can correct the code, then type a type expression to have the same effect in the running code
ipdb is a version of pdb for IPython. It allows the use of pdb with all the IPython features including tab completion.
It is also possible to set pdb to automatically run on an uncaught exception.
Pydb was written to be an enhanced version of Pdb. Benefits?
Problem
What are your best tips for debugging Python? Please don't just list a particular debugger without saying what it can actually do. Related - What are good ways to make my Python code run first time? - This discusses minimizing errors