[Python-ideas] Yield-from: Details to be decided

Guido van Rossum guido at python.org
Fri Feb 20 23:49:44 CET 2009


Good point.

On Fri, Feb 20, 2009 at 2:46 PM, Bruce Frederiksen <dangyogi at gmail.com> wrote:
> Actually, PEP 342 specifies that send(None) is like next():
>
> "Calling send(None) is exactly equivalent to calling a generator's next()
> method."
>
> So to honor this, you would need to have send(None) call next, while
> send(anything_else) raises an exception...
>
> -bruce frederiksen
>
> Greg Ewing wrote:
>>
>> I've got to the point in the implementation where I
>> need to decide what to do if you send() a value to
>> a generator that's delegating to something that
>> doesn't have a send() method.
>>
>> Possibilities include:
>>
>> * Ignore the value and call next() instead
>>
>> * Raise an exception
>>
>> What do people think? I'm inclined to raise an
>> exception for the time being, since we can always
>> relax it later if we want. Also, doing so is more
>> consistent with the idea of the caller talking
>> directly to the sub-iterator.
>>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list