Created
April 27, 2017 18:19
-
-
Save BBischof/d6d4c871c42eb35c00741cdc7aeedbb1 to your computer and use it in GitHub Desktop.
A nice python coding question
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
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