[issue28064] String executed inside a function ignores global statements
Xiang Zhang
report at bugs.python.org
Sat Sep 10 15:10:57 EDT 2016
Xiang Zhang added the comment:
Not a bug. Put the global statement inside:
>>> variable = 'test'
>>> def changeVariable():
... exec("global variable; variable = 'newText'")
...
>>> changeVariable()
>>> print(variable)
newText
----------
nosy: +xiang.zhang
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28064>
_______________________________________
More information about the Python-bugs-list
mailing list