Created
February 1, 2018 10:19
-
-
Save goyalrohit/2826684ace0e6466847e223cd8444bd6 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
import contextlib | |
import sys | |
@contextlib.contextmanager | |
def logging_context_manager(): | |
print('logging_context_manager: enter') | |
try: | |
yield 'You are in a with-block!' | |
print('logging_context_manager: normal exit') | |
except Exception: | |
print('logging_context_manager: exceptional exit',sys.exc_info()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment