[Tutor] WinPdb?

Alan Gauld alan.gauld at btinternet.com
Fri Aug 10 01:31:28 CEST 2007


"Dick Moores" <rdm at rcblue.com> wrote

> The only debugging I've done so far is to put in print statements 
> where I want to see what's happening. 

Thats OK for basic stuff but for complex things you can wind up 
with an awful lot of printing going on!

> However, I just discovered that my excellent (IMO) Python editor, 
> Ulipad, comes with WinPdb, and I'm thinking it's about time 
> I learned how to use a debugger. 

Everyone should, they are wonderful tools provided you stay 
in control.

> But first, could I get some reviews here of WinPdb 

Its very good, I think the one in eclipse/PyDev is slightly better 
but its close. Its certainly better than either IDLE or Pythonwin.

The main thing in using debuggers is to avoid the temptation to 
just start the program and step all the way through. Learn to use 
a combination of break points - to target a suspect function or 
control structure and watches - the equivalent of your print 
statements. If the debugger supports conditional watches so 
much the better, then you only get output when the value 
goes to a particular condition.

Once you've broken the flow at a suspect function and shown 
a known error via a watch set another break point at the next 
level up then rerun to there (conditional break points are great 
too but I don't think pdb does those...) only then do you need 
to start stepping line by line until you see the bug occur.

At that point give up on the debugger and engage your brain!

BTW If you can get a copy of my book (the paper one - a 
library mebbe?) there is a chapter in there about debugging 
which includes the use of raw pdb...

HTH,

Alan G



More information about the Tutor mailing list