Coroutines: unexpected behaviour

Jérôme Mainka jmainka at gmail.com
Wed Jun 16 18:15:21 EDT 2010


On 16 juin, 20:11, Carl Banks <pavlovevide... at gmail.com> wrote:

> I suggest, if you intend to use this kind of thing in real code (and I
> would not recommend that) that you get in a habit of explicitly
> closing the generator after the last send(), even when you don't think
> you have to.

Very clear explanation. Thanks for the investigation...


> IMHO, coroutines are the one time during the PEP-era that Python can
> be accused of feature creep.  All other changes seemed driven by
> thoughtful analysis, this one seemed like it was, "OMG that would be
> totally cool".  PEP 342 doesn't give any compelling use cases (it only
> gives examples of "cool things you can do with coroutines"), no
> discussion on how in improves the language.  Suffice to say that,
> thanks to this example, I'm more averse to using them than I was
> before.

The wonderful David Beazley's course [1] piqued my curiosity. But,
indeed, this is a hard piece difficult to master.


Thanks again,

Jérôme

[1] http://www.dabeaz.com/coroutines/



More information about the Python-list mailing list