T
TP
Hi everybody,
Try the following program:
####################
def f():
def f_nested():
exec "a=2"
print a
f()
####################
It yields an error.
$ python nested_exec.py
File "nested_exec.py", line 3
exec "a=2"
SyntaxError: unqualified exec is not allowed in function 'f_nested' it is a
nested function
What is the problem?
Why?
Thanks
--
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
9&1+,\'Z4(55l4('])"
"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)
Try the following program:
####################
def f():
def f_nested():
exec "a=2"
print a
f()
####################
It yields an error.
$ python nested_exec.py
File "nested_exec.py", line 3
exec "a=2"
SyntaxError: unqualified exec is not allowed in function 'f_nested' it is a
nested function
What is the problem?
Why?
Thanks
--
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
9&1+,\'Z4(55l4('])"
"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)