[Python-ideas] Change how Generator Expressions handle StopIteration
Greg
greg.ewing at canterbury.ac.nz
Wed Nov 5 02:18:39 CET 2014
On 5/11/2014 1:55 p.m., Terry Reedy wrote:
> There is already a 'default' option, so the two would have to be
> mutually exclusive.
>
> "next(iterator[, default])
If it were a keyword-only argument, there wouldn't be any
conflict.
But I'm not sure I like the idea of adding more complexities
to the iterator protocol.
Anything that changes the signature of __next__ or __iter__
would be a bad idea, since all existing iterables
would need to be updated to take it into account.
If this is is to be done, it might be better to add a new
optional dunder method, so that existing iterables would
continue to work.
--
Greg
More information about the Python-ideas
mailing list