Skip to content

Instantly share code, notes, and snippets.

@yuuichi-fujioka
Created August 19, 2014 00:08
Show Gist options
  • Save yuuichi-fujioka/645b620b93b58ba506e5 to your computer and use it in GitHub Desktop.
Save yuuichi-fujioka/645b620b93b58ba506e5 to your computer and use it in GitHub Desktop.
very simple way to implementation of with statement
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