Skip to content

Instantly share code, notes, and snippets.

@ryanwilsonperkin
Created November 18, 2016 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwilsonperkin/1ed0efe5f79b43bc57ab72e53f758a72 to your computer and use it in GitHub Desktop.
Save ryanwilsonperkin/1ed0efe5f79b43bc57ab72e53f758a72 to your computer and use it in GitHub Desktop.
# Having fun with context managers
from contextlib import contextmanager
@contextmanager
def deity():
print 'The Father'
yield
print 'The Holy Ghost'
god = deity()
with god as my_witness:
print 'The Son'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment