New submission from john zeng <[email protected]>:
Can you help me understand why variable `u' is not accessible after
exec()? Is this sort of a late binding issue?
def test(v1):
print(v1)
print("Before exec(): " + str(locals()))
exec(v1)
print("After exec(): " + str(locals()))
# This fails:
# print(u)
# This is workaround:
en = locals()['u']
print(en)
v1="u=4"
test(v1)
----------
components: Interpreter Core
messages: 92409
nosy: ooev
severity: normal
status: open
title: exec(), locals() and local variable access
type: behavior
versions: Python 3.1
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue6862>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com