Prev: Generating diagrams from PostgreSQL with Python (Re:postgresql_autodoc in Python?)
Next: ctypes / cygwin / django+geos
From: Jean-Michel Pichavant on 10 Dec 2009 07:57 Guys, I have some problem changing method locals with pdb: import pdb def test(): foo = 'foo' pdb.set_trace() test() --Return-- > /home/jeanmichel/trunk/tnt/test.py(5)test()->None -> pdb.set_trace() (Pdb) print foo foo (Pdb) foo = 'bar' (Pdb) print foo foo (Pdb) I tried using locals() but it returns a copy of the locals. So changing locals['foo'] won't do any good. (Pdb) locals() Out[6]: {'__return__': None, 'foo': 'foo'} Any idea ? I'm starting to wonder if it is possible. JM
From: Diez B. Roggisch on 10 Dec 2009 08:04
Jean-Michel Pichavant wrote: > Guys, > > I have some problem changing method locals with pdb: > > import pdb > > def test(): > foo = 'foo' > pdb.set_trace() > > test() > --Return-- > > /home/jeanmichel/trunk/tnt/test.py(5)test()->None > -> pdb.set_trace() > (Pdb) print foo > foo > (Pdb) foo = 'bar' > (Pdb) print foo > foo > (Pdb) > > > I tried using locals() but it returns a copy of the locals. So changing > locals['foo'] won't do any good. > (Pdb) locals() > Out[6]: {'__return__': None, 'foo': 'foo'} > > > Any idea ? I'm starting to wonder if it is possible. I recall having some issues with local variables sometimes, but actually your example works fine for me: def test(): foo = "foo" import pdb; pdb.set_trace() print foo test() And the session: $ python /tmp/test.py > /tmp/test.py(9)test() -> print foo (Pdb) pp foo 'foo' (Pdb) foo = "bar" (Pdb) n bar --Return-- > /tmp/test.py(9)test()->None -> print foo (Pdb) c Diez |