(Jun-14-2021, 01:01 PM)Larz60+ Wrote: 1st you should avid using exec
It does work:
>>> def test(): ... exec("a=100") ... print(a) ... >>> test() 100 >>>The proper way:
>>> def test(): ... a = 100 ... print(a) ... >>> test() 100 print(a)
>>> def test(): ... exec("a=100") ... print(a) ... >>> test() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in test NameError: name 'a' is not definedWhich version are you using? I am using 3.9.5 and it does not work.