Why PDB is my favorite thing in python


At visual effects companies we have a lot of code, and a lot of the code is old and complicated. Sometimes is it troublesome to find out why something is behaving the way it is. Where is this value coming from and what is this variables type? There are a few ways you can answer these questions. You could litter your code with print statements or other methods. The one I find the most effective and pleasant to use is pdb, in particular pdb++.

Pdb is a python debugger that lets you step through your code line by line, monkey patch, and find where things are breaking. Out of the box, pdb has some great uses

https://docs.python.org/2/library/pdb.html

But to take this a step farther, there is pdb++ that has added features and a great display in the shell that makes it pleasant to walk through your code.

https://pypi.org/project/pdbpp/

If you find yourself working with a large and complex code base, knowing this tool will save you a bunch of time.

Leave a Reply

Your email address will not be published. Required fields are marked *