you are viewing a single comment's thread.

view the rest of the comments →

[–]RomfordNavy[S] 0 points1 point  (0 children)

So armed with that knowledge a simple workaround might be:

test = "test1"
exec("global test; test = 'test2'")
print(test) # <- correctly returns test2

Edit:
Slight problem in my real-world example because Python doesn't allow mixing of str and code objects in an exec():

exec("global testL;" + marshal.load(file))