Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Dale Roberts
On Apr 19, 6:10 am, Peter Otten <__pete...@web.de> wrote: > ... > 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 thought I'd chim

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Dale Roberts
On Apr 17, 10:07 pm, Aaron Brady wrote: > You can do it with a wrapping generator.  I'm not sure if it > interferes with your needs.  It calls 'next' the first time, then just > calls 'send' on the parameter with the value you send it. Aaron, Thanks for the hint. I'd made a modified version of m

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Aahz
In article , Peter Otten <__pete...@web.de> wrote: > >Generators at the moment seem to have turned into what in German we call >an "eierlegende Wollmilchsau"*. One more point: there has always been a tension within the Python community between people pushing the bleeding edge and people who prefe

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Aahz
In article , Peter Otten <__pete...@web.de> wrote: >Aahz wrote: >> In article >> <07ad771b-a6d1-4f08-b16c-07caf7462...@e18g2000yqo.googlegroups.com>, >> Michele Simionato wrote: >>>On Apr 18, 3:03=A0pm, a...@pythoncraft.com (Aahz) wrote: In article , Peter Otten =A0<__pete...@web.de> w

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Peter Otten
Aahz wrote: > In article > <07ad771b-a6d1-4f08-b16c-07caf7462...@e18g2000yqo.googlegroups.com>, > Michele Simionato wrote: >>On Apr 18, 3:03=A0pm, a...@pythoncraft.com (Aahz) wrote: >>> In article , >>> Peter Otten =A0<__pete...@web.de> wrote: If it were up to me I'd rip out send() imme

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-19 Thread Michele Simionato
On Apr 19, 8:09 am, Michele Simionato wrote: > Coroutines instead could have been implemented as > a library, without requiring any syntax change. Here is a proof of principle, just to make clearer what I have in mind. Suppose you have the following library: $ cat coroutine.py from abc import abs

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Michele Simionato
On Apr 18, 5:19 pm, a...@pythoncraft.com (Aahz) wrote: > Okay, I'm curious, is the argument that you shouldn't use generators for > coroutines or something else? Yes, there is certainly the confusion between generators and coroutines (the ones David Beazley warns about). At first, I was a support

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Aahz
In article <07ad771b-a6d1-4f08-b16c-07caf7462...@e18g2000yqo.googlegroups.com>, Michele Simionato wrote: >On Apr 18, 3:03=A0pm, a...@pythoncraft.com (Aahz) wrote: >> In article , >> Peter Otten =A0<__pete...@web.de> wrote: >>> >>>If it were up to me I'd rip out send() immediatly. At first I thoug

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Michele Simionato
On Apr 18, 3:03 pm, a...@pythoncraft.com (Aahz) wrote: > In article , > Peter Otten  <__pete...@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 happened. > > Too late -- it's likely t

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Aahz
In article , Peter Otten <__pete...@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 happened. Too late -- it's likely to get an upgrade for 3.1 and 2.7. Basically, send() is useful for cor

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-18 Thread Peter Otten
Dale Roberts wrote: > I've started using generators for some "real" work (love them!), and I > need to use send() to send values back into the yield inside the > generator. When I want to use the generator, though, I have to > essentially duplicate the machinery of a "for" loop, because the "for"

Re: send() to a generator in a "for" loop with continue(val)??

2009-04-17 Thread Aaron Brady
On Apr 17, 3:59 pm, Dale Roberts wrote: > I've started using generators for some "real" work (love them!), and I > need to use send() to send values back into the yield inside the > generator. When I want to use the generator, though, I have to > essentially duplicate the machinery of a "for" loop

send() to a generator in a "for" loop with continue(val)??

2009-04-17 Thread Dale Roberts
I've started using generators for some "real" work (love them!), and I need to use send() to send values back into the yield inside the generator. When I want to use the generator, though, I have to essentially duplicate the machinery of a "for" loop, because the "for" loop does not have a mechanis