SHARE
TWEET

Untitled

a guest Dec 17th, 2011 35 Never
  1. >>> exec("x=3")
  2. >>> x
  3. 3
  4. >>> def foo():
  5. ...     exec("blah=4")
  6. ...     print(blah)
  7. ...
  8. >>> foo()
  9. Traceback (most recent call last):
  10.   File "<stdin>", line 1, in <module>
  11.   File "<stdin>", line 3, in foo
  12. NameError: global name 'blah' is not defined
RAW Paste Data
Top