Created
February 1, 2018 10:16
-
-
Save goyalrohit/0268b66a1fcd02573ba4eccc5cddcfd7 to your computer and use it in GitHub Desktop.
This file contains 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 LoggingContextManager: | |
def __enter__(self): | |
print('LoggingContextManager.__enter__()') | |
return "You are in a with block" | |
def __exit__(self, exc_type, exc_val, exc_tb): | |
if exc_type is None: | |
print('LoggingContextManager.__exit__:' | |
'normal exit detected.') | |
else: | |
print('LoggingContextManager.__exit__:' | |
'Exception Detected' | |
'type={}, value={}, traceback={}'.format(exc_type, exc_val, exc_tb)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment