stop exeuction and give my a prompt

Syver Enstad syver-en+usenet at online.no
Tue Apr 1 19:38:05 EST 2003


David Bear <david.bear at asu.edu> writes:

> I would like to have the ability to insert a statement in my code that
> would
> 
> stop program execution at that point and give me a python prompt.  I
> don't
> 
> know what to call this. 
> 
> What I would like to do is to stop program execution and inspect the
> state
> 
> of certain dictionaries --- I don't want to insert a bunch of print 
> statements and watch output fly of the screen.  I'd also like to be
> able to
> 
> fiddle with these dictionaries when my program stops.  
> 
> Any pointers?

Use the python debugger. In the most primitive way is to use it from
the interactive prompt.

Do:

import pdb # at the top of your sourcefile

Do:

pdb.set_trace() # at the point you want to debug.

I use some magic that I found at the python cookbook that gives me a
debugger prompt if the python program I am running crashing (so called
Just In Time debugging).

For a more pleasant debugging environment check out Emacs or Pythonwin.
-- 

Vennlig hilsen 

Syver Enstad




More information about the Python-list mailing list