Created
March 1, 2014 01:10
-
-
Save wolever/9283224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python 2: | |
$ python-2.7 finallyfun.py | |
e: Exception() | |
Python 3: | |
$ python3.3 finallyfun.py | |
Traceback (most recent call last): | |
File "finallyfun.py", line 9, in <module> | |
foo() | |
File "finallyfun.py", line 7, in foo | |
print("e: %r" %(e, )) | |
UnboundLocalError: local variable 'e' referenced before assignment | |
""" | |
def foo(): | |
e = None | |
try: | |
raise Exception() | |
except Exception as e: | |
pass | |
finally: | |
print("e: %r" %(e, )) | |
foo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment