How to debug python code?

Johannes Nix Johannes.Nix at web.de
Mon Apr 3 10:34:19 EDT 2006


Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:

> 	My typical debugging technique is the infamous "wolf fence" (there's
> one wolf in Alaska, how do you find it? First build a fence down the
> middle of the state, wait for the wolf to howl, determine which side of
> the fence it is on. Repeat process on that side only, until you get to
> the point where you can see the wolf). In other words; put in a few
> "print" statements until you find the statement that is failing (then
> maybe work backwords from the "tracks" to find out where the wolf/bug
> comes from).


I think the advantage of this method is that one has to become
clear what the state of the program should look like.

For the same reason, unit tests may help to develop a
proper specification of the task of a module.

However, pdb's port mortem debugging can be helpful when a 
program takes a lot of time to hit the error, and
a large amount of data is in play, for example for
numerical computations.

Johannes



More information about the Python-list mailing list