send() to a generator in a "for" loop with continue(val)??
__peter__ at web.de
Sun Apr 19 12:10:51 CEST 2009
> In article
> <07ad771b-a6d1-4f08-b16c-07caf74623c3 at e18g2000yqo.googlegroups.com>,
> Michele Simionato <michele.simionato at gmail.com> wrote:
>>On Apr 18, 3:03=A0pm, a... at pythoncraft.com (Aahz) wrote:
>>> In article <gsc7e1$rj6$0... at news.t-online.com>,
>>> Peter Otten =A0<__pete... at web.de> wrote:
>>>>If it were up to me I'd rip out send() immediatly. At first I thought I
>>>>would see a compelling use case and be enlightened, but it never
>>> Too late -- it's likely to get an upgrade for 3.1 and 2.7. Basically,
Could you give some details or a link?
>>> send() is useful for coroutines, and if you haven't yet read
>>> you really should (assuming you want to continue arguing).
I only just started reading Beazley's presentation, it looks interesting.
Thanks for the hint!
Are you currently using coroutines in Python? If so, what kind of practical
problems do they simplify for you?
>>I suspect Peter knows everything about coroutines and still he is not
>>convinced about .send. FWIW, I am sympathic with him.
> Okay, I'm curious, is the argument that you shouldn't use generators for
> coroutines or something else?
I don't know nearly as much about coroutines as Michele thinks; in
particular I have no practical experience with them.
What I've seen so far is that the once beautifully simple generator
mechanism has become very complex with the recent additions for ressource
management and coroutines.
Generators as filters and synthetic sequences are now ubiquitous, the with
statement is spreading like wildfire.
The send()/yield-expression duo on the other hand is limping along, and
someone like Michele who is definitely in the "intended audience" for the
more arcane features of Python says that you can do it with a library.
If that is possible shouldn't it have been the first step to put such a
library into the stdlib and see how it fares?
Generators at the moment seem to have turned into what in German we call
an "eierlegende Wollmilchsau"*.
More information about the Python-list