Created
August 19, 2014 00:08
-
-
Save yuuichi-fujioka/645b620b93b58ba506e5 to your computer and use it in GitHub Desktop.
very simple way to implementation of with statement
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
from contextlib import contextmanager | |
@contextmanager | |
def wrapper(): | |
print 'enter' | |
yield | |
print 'exit' | |
def main(): | |
with wrapeer(): | |
print 'hello world' | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment