[Python-ideas] generator.close

Mark Shannon mark at hotpy.org
Wed Apr 11 12:04:29 CEST 2012


Matt Joiner wrote:
> Why can't generator.close() return the value if a StopIteration is raised?

No reason as far as I can see. The semantics are clear enough.
 From an implementation point of view it would be a simple patch.

> 
> The PEPs mentioned that it was proposed before, but I can't find any 
> definitive reason, and it's terribly convenient if it does.

I'm sure it is convenient, but I believe it is convention to provide a
use case ;)

Cheers,
Mark.



More information about the Python-ideas mailing list