[Python-Dev] Request for clarification of PEP 380

Mark Shannon mark at hotpy.org
Thu Mar 8 16:08:48 CET 2012


Nick Coghlan wrote:
> On Fri, Mar 9, 2012 at 12:06 AM, Mark Shannon <mark at hotpy.org> wrote:
>> The text of the PEP seems to implicitly assume that all sub-iterators
>> will be generators, so it is not clear on the above points.
> 
> On the contrary, this question is explicitly addressed in the PEP:
> http://www.python.org/dev/peps/pep-0380/#finalization

I should have read it more carefully.

> 
> If you want to block an inadvertent close() call, you need to either
> wrap the object so it doesn't implement unwanted parts of the
> generator API (which is the iterator protocol plus send(), throw() and
> close()), or else you should continue to use simple iteration rather
> than delegation.
> 

What about the exception being suppressed?
That doesn't seem to be mentioned.

Cheers,
Mark.



More information about the Python-Dev mailing list