Skip to content

Instantly share code, notes, and snippets.

@shomah4a
Created September 24, 2011 03:49
Show Gist options
  • Save shomah4a/1238933 to your computer and use it in GitHub Desktop.
Save shomah4a/1238933 to your computer and use it in GitHub Desktop.
exec?
import traceback
source = '''
def self():
def test():
assert False
test()
'''
def aaa():
env = {}
exec source in env
env['self']()
def bbb():
exec source
self()
try:
aaa()
except:
traceback.print_exc()
try:
bbb()
except:
traceback.print_exc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment