Skip to content

Instantly share code, notes, and snippets.

@BBischof
Created April 27, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BBischof/d6d4c871c42eb35c00741cdc7aeedbb1 to your computer and use it in GitHub Desktop.
Save BBischof/d6d4c871c42eb35c00741cdc7aeedbb1 to your computer and use it in GitHub Desktop.
A nice python coding question
class B(Exception):
pass
class C(B):
pass
class D(C):
pass
for cls in [B, C, D]:
try:
raise cls()
except D:
print("D")
except C:
print("C")
except B:
print("B")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment