Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 17th, 2011  |  syntax: Python  |  size: 0.25 KB  |  views: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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