Launching pdb from within a script
Graham Nicholls
graham at rockcons.co.uk
Sun Jan 4 16:25:33 EST 2004
Peter Otten wrote:
> 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
I have had a look, but its rather a case of you don't know what you don't
know, IYSWIM.
> documentation - or do something new and dangerous: search google groups
> for, say, Nicholls and set_trace :-)
What a good idea!
Thanks again
PS 1 minute later and I've found the relevant posting, which indeed mentions
using set_trace().
I have in ordinary google searches of course returned ng postings, but had
never used their group searches, so thnkas on two counts.
>
> Peter
Regards
Graham
--
#include <wit>
More information about the Python-list
mailing list