How to set a runtime-variable in pdb-session?

Georg Lohrer rerhol at
Tue Nov 6 18:53:57 CET 2001


I'm just trying to set a variable of a script during
a pdb-session. But whatever I do, the variable does
not been setted accordingly.

For example:

(1) import pdb
(2) class foo:
(3)    def show(self, name_of_var):
(4)      pdb.set_trace()
(5)      x = name_of_var
(6)      print x
(7) if __name__ == '__main__':
(8)    f = foo()

Running with 'python' stops at pdb.set_trace();
after entering one 'n', the current line will be (5).
Now I want to change the value of name_of_var to

(pdb) name_of_var
(pdb) name_of_var='not_my_foo'
(pdb) name_of_var
(pdb) locals()['name_of_var']='not_my_foo'
(pdb) name_of_var

I don't know how to evaluate that local variable
to a specific value on-time.
Do you have any ideas or knowledge?

Ciao, Georg

More information about the Python-list mailing list