Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Broken in Python 3.1.2
- # Python 2.6: prints 'it is working'
- # Python 3.1.2: "NameError: global name 'a_func' is not defined"
- class Testing(object):
- def __init__(self):
- exec("""def a_func():
- print('it is working')""")
- a_func()
- Testing()
- ## Works in both 2.6 and 3.1.2
- # Python 2.6: prints 'it is working'
- # Python 3.1.2: prints 'it is working'
- class Testing(object):
- def __init__(self):
- def a_func():
- print('it is working')
- a_func()
- Testing()
Add Comment
Please, Sign In to add comment