Launching pdb from within a script
Peter Otten
__peter__ at web.de
Sun Jan 4 15:36:55 EST 2004
Graham Nicholls wrote:
> I'm sure I was able to print the value of variables like this:
>
> except :
> pdb.set_trace()
[...]
> But pdb complains that there are no such variables. It may be that I had
> to add some incantation around the script startup - I just can't remember
> (and its frustrating!).
<debugger.py>
import pdb
abc = 1
try:
print "before"
1/0
except:
pdb.set_trace()
print "after"
</debugger.py>
Now run it:
before
--Return--
> /(suppressed)/python2.3/pdb.py(992)set_trace()->None
-> Pdb().set_trace()
(Pdb) abc
*** NameError: name 'abc' is not defined
(Pdb) u
> /(suppressed)/debugger.py(7)?()
-> pdb.set_trace()
(Pdb) abc
1
(Pdb)
If the above sample session doesn't help, you could actually read the pdb
documentation - or do something new and dangerous: search google groups
for, say, Nicholls and set_trace :-)
Peter
More information about the Python-list
mailing list