Skip to content

Instantly share code, notes, and snippets.

@obfusk
Last active August 24, 2023 23:49
Show Gist options
  • Save obfusk/a951133084492817dd7154af197e58fb to your computer and use it in GitHub Desktop.
Save obfusk/a951133084492817dd7154af197e58fb to your computer and use it in GitHub Desktop.
weird python thing
>>> try:
... raise Exception("oops")
... except Exception as e:
... print("A", e)
... try:
... pass # raise Exception("uh-oh")
... except Exception as e:
... print("B", e)
... print("C", e)
...
A oops
C oops
>>> try:
... raise Exception("oops")
... except Exception as e:
... print("A", e)
... try:
... raise Exception("uh-oh")
... except Exception as e:
... print("B", e)
... print("C", e)
...
A oops
B uh-oh
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception: oops
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
NameError: name 'e' is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment