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

Dale Roberts gooberts at gmail.com
Sun Apr 19 17:41:19 EDT 2009


On Apr 17, 10:07 pm, Aaron Brady <castiro... at gmail.com> 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 my generator that
was "for loop aware" and had two yields in it, but this seemed very
fragile and hackish to me, and left my generator only usable inside a
"for" loop.

The wrapper method seems to be a much better way to go.

dale



More information about the Python-list mailing list