views:

1410

answers:

3

Can someone provide me with a brief introduction on how to use Python generators to implement coroutines?

+10  A: 

I suggest you start here:

Coroutines via Enhanced Generators

http://www.python.org/dev/peps/pep-0342/

By Guido van Rossum and Phillip J. Eby

gahooa
+6  A: 

Use the google, Luke.

The latest release of Python (version 2.5) has a new feature called coroutines. This post looks at what coroutines are and how to use them. ...

http://antroy.blogspot.com/2007/04/python-coroutines.html

bendin
"The latest release of Python (version **2.5**)"... Uhh...
Evan Fosmark
The quoted blog article was written April 2007. You don't have to even follow the link to see that, just look at the URL. Python 2.6 wasn't released until October 1, 2008.
bendin
The differences between Python 2.6 and 2.5 are small enough that a 2007 article is NOT uselessly out of date.
S.Lott
and actually this article is a **great** brief introduction to generators and coroutines!
Davide
+14  A: 

This was presented about a month after this question: http://www.dabeaz.com/coroutines/index.html

Dave's presentation is excellent and explains exactly how coroutines can be made with Python 2.5+ - well recommended.

Eli Bendersky
Oh wow, this is +10 (the link is my canonical reference for Python coroutines)
kaizer.se