Closed FarukHammoud closed 6 years ago
When I run this program I see 2
.
It only works when you run it out of 'setup' or 'draw'.
The same program will fail in the same way in CPython as well.
def foo():
exec('def A(n): return n\ndef B(n): return A(n)\nprint(B(12)) \n')
foo()
NameError: global name 'A' is not defined
Hint:
def foo():
exec('global A\ndef A(n): return n\ndef B(n): return A(n)\nprint(B(12)) \n')
foo()
A normal Python interpreter returns 2 when I execute : exec('def Soma(n): return n \ndef Soma2(n): return Soma(n) \nprint(Soma2(2)) \n')
But it doesn't work with Processing Python's 'exec', it return an error : global name 'Soma' is not defined
Someone knows why?