[Python-ideas] Revised**12 PEP on Yield-From

Jacob Holm jh at improva.dk
Sun Apr 19 15:58:39 CEST 2009


Nick Coghlan wrote:
> Greg Ewing wrote:
>>     * ``return expr`` in a generator causes ``StopIteration(expr)`` to
>>       be raised.
> 
> One minor nit here - this bullet point is somewhat ambiguous as to where
> the raised exception is visible. It is probably worth mentioning
> explicitly that as with existing "return" statements in generators, the
> StopIteration exception won't be seen in the generator's own frame.
> 


It is mentioned later, in the formal semantics,

> ...
> except that, as currently, the exception cannot be caught by ``except``
> clauses within the returning generator.

but I agree that it probably wouldn't hurt to mention it earlier as well.


> As someone else mentioned on another recent draft, it may be worth
> including some of the toy examples we were playing with in some of the
> discussion threads. Sure, they weren't all that practical, but they
> seemed to do a good job of getting the data flow concepts across.
> 


It may be good enough just to include links to the relevant messages in 
the PEP.  Getting some small examples in the actual docs is probably 
more important.


> Otherwise looks good to me.
> 


There is a minor issue with the handling of throw in the expansion, but 
otherwise I agree.

Cheers
- Jacob



More information about the Python-ideas mailing list