Created
June 10, 2016 22:04
-
-
Save brake/dab502af724163292ee88e0cb5cac3f6 to your computer and use it in GitHub Desktop.
Python decorator turning generator into coroutine
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
| def coroutine(gen_fn): | |
| """Python decorator turning generator into coroutine""" | |
| def inner(*args, **kwargs): | |
| gen = gen_fn(*args, **kwargs) | |
| gen.next() | |
| return gen | |
| return inner | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment