Debugging in Py

Tim Chase python.list at tim.thechases.com
Wed Mar 25 16:52:56 CET 2009


> I'm just wondering if you all have any resources on Debugging that you
> all would "recommend." Due to the fact I'm doing some debugging as a
> beginner and this has the best of me, and I'm looking at trying to
> learn more about what and how to debug within Py using print, and
> etc...

For most of what I do, simply dropping a "print" line suffices. 
For more complex stuff where I want to do a bit of on-the-fly 
inspection, I'll often just add the line

   import pdb; pdb.set_trace()

to my code and it will halt at a debugger prompt.  You can then 
use the batteries-included "pdb" debugger to inspect your 
program's internal state.

You can read up on it at

http://docs.python.org/library/pdb.html#id1
http://www.oreillynet.com/pub/a/python/2005/09/01/debugger.html
http://www.ferg.org/papers/debugging_in_python.html

I use it mostly to dump variable contents and step into/over 
lines of code (there are much deeper abilities that I hardly 
scratch).

-tkc







More information about the Python-list mailing list