[Python-ideas] Revised**11 PEP on Yield-From
Jacob Holm
jh at improva.dk
Sat Apr 18 00:39:21 CEST 2009
Greg Ewing wrote:
> Jacob Holm wrote:
>
>> 1. Throwing StopIteration to an iterator without a throw() method.
>
> Guido seems happy not to care what happens if you
> throw StopIteration in, so I'm happy to do so as
> well -- it saves considerable complication.
I was about to reiterate how treating a missing throw like I suggested
would make my wrappers simpler, but realized that it actually makes very
little difference.
>
> > What should happen with an iterator that has a
>> throw or close attribute that just happens to have the value None?
> > The expansion handles it as if the attribute wasn't there
>
> That's a good point -- I hadn't intended that.
Ok.
Note that treating None as missing might actually be useful by making it
easier to "hide" the throw() or close() method of a base class from
yield-from. IIRC there is a precedent for treating None this way in the
handling of hash().
Even without handling None this way it is still possible to hide the
base class methods by creating a property that raises AttributeError, so
this is not all that important.
I just think that using None is slightly cleaner for this use.
Cheers
- Jacob
More information about the Python-ideas
mailing list