Last active
October 21, 2015 04:39
-
-
Save Dunes/da9ad871b91f6f3b0f55 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
class MyContextManager: | |
def __enter__(self): | |
return self | |
def __exit__(self, type_, value, traceback): | |
# marks exception as being handled, and so it is not re-raised outside of the with block | |
return True | |
with MyContextManager(): | |
raise ValueError | |
data = None | |
print(data) # raises NameError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment