Skip to content

Instantly share code, notes, and snippets.

@letoh
Created June 19, 2012 10:35
Show Gist options
  • Select an option

  • Save letoh/2953452 to your computer and use it in GitHub Desktop.

Select an option

Save letoh/2953452 to your computer and use it in GitHub Desktop.
coroutine
def coroutine(f):
_co = f()
return lambda : _co.next
@coroutine
def foo():
for i in xrange(5):
yield i
a = foo()
while 1:
try:
print a()
except:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment