Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
You can’t perform that action at this time.