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

Guido van Rossum guido at python.org
Sat Feb 21 17:31:21 CET 2009

On Fri, Feb 20, 2009 at 10:09 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Bruce Frederiksen wrote:
>> Actually, PEP 342 specifies that send(None) is like next():
>> "Calling send(None) is exactly equivalent to calling a generator's next()
>> method."
> Hmmm, yes, but... that's talking about what happens
> when you call send() on a *generator*.
> But when yield-from is delegating to some iterator
> that's not a generator, according the current wording
> in the PEP, things are supposed to behave as though
> you were talking directly to the iterator. If it
> doesn't have a send() method, and you tried to call
> it directly, you would get an exception.
> We're in unprecedented territory here, and it's hard
> to tell what will turn out to be the most useful
> behaviour without more experience. Raising an
> exception for now seems like the safest thing to
> do.

Agreed after all.

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

More information about the Python-ideas mailing list