Wednesday, December 30, 2015

Python debugging: ipdb

pdb is python's basic debugger.  It's nice because you can use it in a lot of different circumstances and it's independent of any particular IDE.

Here's a nice introduction:

But most often, if I pull out a debugger, what I really want is to play with the objects in a python shell.  pdb has its own shell, but . . . there are a lot of missing features.  In particular, if you want to explore a particular object it's weak because there isn't a tab completion feature.

If you already have ipython, you can use the pdb functionality of pdb in the more powerful ipython shell by using ipdb.

It's simple to install and more than worth it.  Just do

pip install ipdb.

Then, instead of 
'import pdb'

do 
'import ipdb'

and instead of 
pdb.set_trace()

do 
ipdb.set_trace().

You're welcome!


No comments:

Post a Comment