[Python-ideas] Revised revised revised PEP on yield-from

Steven D'Aprano steve at pearwood.info
Sat Feb 14 05:14:00 CET 2009


Raymond Hettinger wrote:

> The proto-pep seems heavy on specification and light on
> showing that this is actually something we want to have.
> Plenty of folks have shown an interest in a basic version
> of yield-every or yield-from, but prior to this protoPEP,
> I've never seen any request for or discussion of a version
> that does pass-throughs for send/throw/close.

What he said.

I'm +1 on a basic pass-through "yield from". I understand the motivation 
in the protoPEP (factoring out parts of a generator into other 
generators), but it's not clear how genuinely useful this is in 
practice. I haven't used threads, and the motivating use case doesn't 
mean anything to me.

If I've understood the protoPEP, it wraps four distinct pieces of 
functionality:

"yield from" pass-through
pass-through for send
pass-through for throw
pass-through for close

I think each one needs to be justified, or at least explained, 
individually. I'm afraid I'm not even clear on what pass-through for 
send/throw/close would even mean, let alone why they would be useful. 
Basic yield pass-through is obvious, and even if we decide that it's 
nothing more than syntactic sugar for "for x in gen: yield x", I think 
it's a clear win for readability. But the rest needs some clear, simple 
examples of how they would be used.



-- 
Steven




More information about the Python-ideas mailing list