[Tutor] print stack traces not caused by errors

ALAN GAULD alan.gauld at btinternet.com
Wed Jan 5 02:42:55 CET 2011



> and I will  figure out how to get more. I will definitely look at
> setting breakpoints in  the event handlers (every event is fired by a
> keystroke controled in an  accelerator table). 

It doesn't matter about the events, only the handler.
Provided you know the handler function that gets called you 
can set the break point on the function.

(pdb) b foo

will stop at the entry to foo()

If you can happen to find a paper copy of my book there is a 
chapter in there about debugging whjich includes examples 
of using pdb and the IDLE debugger. (This is one of the few 
chapters that is not available on the web site).

> problems that is hard to track down  since it seems to happen randomly,

If you use Pythons debugger you can set a group of variables 
to display every time you stop (you can do it in pdb too but its 
much more work!). That can help you  quickly compare values 
of key variables and see which is causing the problem.

but a simple print/raw_input in the code will do much the same...

Alan G.



More information about the Tutor mailing list