does exec ignore the locals parameter?
cburns4563 at gmail.com
Fri Jan 23 01:45:19 CET 2009
In the code below, bar() seems to work, foo() seems broken.
% python -V
% cat exec1.py
def foo(i) :
exec "i = i + 1" in locals(), globals()
print "i=%d" % i
def bar(j) :
exec "j = j + 1"
print "j=%d" % j
% python exec1.py
What I really wanted to do was something like:
exec text in globals(), inspect.currentframe(1).f_locals but
that didn't work either.
More information about the Python-list