[issue28064] String executed inside a function ignores global statements

Qwert225 report at bugs.python.org
Sat Sep 10 13:14:53 EDT 2016


New submission from Qwert225:

String executed inside a function ignores global statements stated before string execution.

See the example below - the global variable value should be changed to 'newText' by the function, but is not.
Example:

variable = 'text'

def changeVariable():
    global variable
    exec("variable = 'newText'")

changeVariable()

print(str(variable))

----------
messages: 275657
nosy: Qwert225
priority: normal
severity: normal
status: open
title: String executed inside a function ignores global statements
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28064>
_______________________________________


More information about the Python-bugs-list mailing list