On Tue, Nov 25, 2014 at 1:05 PM, Guido van Rossum firstname.lastname@example.org wrote:
(You could point out that I don't do anything about the similar problem when the outer iterator is implemented as a class with a __next__() method.
Indeed -- that is the key point here -- but you were pretty clear about how special casing StopIteration is a non-starter.
If I could, I would -- but that case is different because there you *must* raise StopIteration to terminate the iteration, so it becomes more similar to an accidental KeyError being masked when it occurs inside a __getitem__() method.
Well, I guess it a good thing to make things easier/clearer where you can -- even if you can't do it everywhere.
I suppose if you think of generator functions as an easier way to write an iterator (where it makes sense) then this is one more thing that makes it even easier easier / safer. It does even more of the book keeping for you. So a consistent win-win.
Thanks for the time taken clarifying your point.
But not a big deal, agreed, probably a much smaller deal that all the other
stuff you'd better understand to write this kind of code anyway.
Which I'm sorry to see is much less widely understood than I had assumed.
Well, this PEP does make for one less detail you need to understand (or more to the point, keep in mind) when writing generator functions -- so that's a good thing.