Created
August 21, 2014 15:48
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from contextlib import contextmanager | |
@contextmanager | |
def ctxmgr(): | |
print('before') | |
def inner_generator(): | |
while True: | |
print((yield)) | |
generator = inner_generator() | |
next(generator) | |
yield generator | |
print('after') | |
if __name__ == '__main__': | |
with ctxmgr() as c: | |
c.send('inner') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment