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

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


Hi,

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()
(9)    f.show('myfoo')

Running with 'python foo.py' 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
'not_my_foo'.

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

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