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

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Feb 21 07:09:51 CET 2009


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.

-- 
Greg



More information about the Python-ideas mailing list