changing local variable values in python debugger

Richie Hindle richie at
Fri Sep 17 15:43:55 CEST 2004

> 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\
-> if f == 'd':
(Pdb) f
(Pdb) f = 'd'
(Pdb) s
> c:\src\tests\
-> 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

More information about the Python-list mailing list