updated from Atlas

This commit is contained in:
Luciano Ramalho
2015-04-15 04:48:25 -03:00
parent f4cdee2447
commit f86aee2785
78 changed files with 587 additions and 333 deletions

12
16-coroutine/coroutil.py Normal file
View File

@@ -0,0 +1,12 @@
# BEGIN CORO_DECO
from functools import wraps
def coroutine(func):
"""Decorator: primes `func` by advancing to first `yield`"""
@wraps(func)
def primer(*args,**kwargs): # <1>
gen = func(*args,**kwargs) # <2>
next(gen) # <3>
return gen # <4>
return primer
# END CORO_DECO