From anonymous, 5 Months ago, written in Plain Text.
Embed
  1. """Beschreibe diese Funktion …
  2. """
  3. def foo():
  4.   bar()
  5.  
  6. """Beschreibe diese Funktion …
  7. """
  8. def bar():
  9.   print('abc')
  10.  
  11.  
  12. foo()
  13. ('__doc__', 'foo', 'bar')
  14. Traceback (most recent call last):
  15.   File "", line 51, in run_code
  16.     exec(code, {}, {})
  17.   File "<string>", line 12, in <module>
  18.   File "<string>", line 4, in foo
  19. NameError: name 'bar' is not defined
  20.  
  21.  
  22.  
  23. def run_code(src):
  24.     print(src.strip())
  25.     try:
  26.         code = compile(src, '<string>', 'exec')
  27.         print(_names)
  28.         exec(code, {}, {})
  29.     except Exception as e:
  30.         traceback.print_exc()