[Python-ideas] Generators are iterators

random832 at fastmail.us random832 at fastmail.us
Wed Dec 10 20:14:21 CET 2014


On Wed, Dec 10, 2014, at 07:36, Oscar Benjamin wrote:
> Many iterators perform other kinds of exception handling without
> allowing that to fall through and many iterators catch StopIteration
> from child iterators without reraising it. This has never lead anyone
> to suggest that such iterators are not true iterators in any way.

The problem isn't what they do when the child iterator raises
StopIteration. That's always been well-defined as "treat that particular
child iterator as having ended" and behave however the function wants to
treat that case (e.g. chain moves on to the next argument). The question
is what they should do when *one of their other inputs* (such as a map
or filter function) raises StopIteration.


More information about the Python-ideas mailing list