painful debugging: techniques?

Roger Binns rogerb at rogerbinns.com
Wed Apr 7 01:10:42 EDT 2004


> I'm wondering if there are tricks people use to track down problems like
> this.

I do two things.  One is that I catch exceptions and print out the
variables for each frame, in addition to the traceback.  The recipe
is at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52215

The second thing is that I never start the program in the debugger.
If I actually need to debug somewhere, I add the following line:

    import pdb ; pdb.set_trace()

You will then pop into the debugger at that point, and can step
through the code.  The above statement can be inside an if
or any other condition, so I only triggers at the point that
is relevant.

Roger





More information about the Python-list mailing list