changing local variable values in python debugger

Richie Hindle richie at entrian.com
Fri Sep 17 09:43:55 EDT 2004


[Jeremy]
> Is there any way to modify a local variable in the Python debugger (pdb)?
> [...]
> (Pdb) f
> 'a'
> (Pdb) f = 'd'
> (Pdb) f
> 'a'

In fact what you're doing there *is* working - look:

> c:\src\tests\jeremy-pdb.py(9)main()
-> if f == 'd':
(Pdb) f
'b'
(Pdb) f = 'd'
(Pdb) s
> c:\src\tests\jeremy-pdb.py(10)main()
-> b(f)

Setting the value of a local variable works, but *examining* the value resets
it to whatever it was when you arrived at the current pdb prompt.  It's a bug,
either in pdb or in Python's core debugger support depending on how you look
at it.  I've been meaning to try to fix this for ages, but haven't found the
time to figure out how to do so.

-- 
Richie Hindle
richie at entrian.com




More information about the Python-list mailing list