[Python-ideas] sentinel_exception argument to `iter`
Ram Rachum
ram.rachum at gmail.com
Fri Feb 7 11:01:44 CET 2014
On Friday, February 7, 2014 11:49:12 AM UTC+2, Stephen J. Turnbull wrote:
>
> Steven D'Aprano writes:
>
> > iter(func, "NOBODY expects the Spanish Inquisition!!!")
>
> +1 Code Snippet of the Week!
>
A++, would run again :)
Now back to serious discussion: I do prefer a separate keyword argument
rather than reusing `sentinel`. If `sentinel_exception` is too verbose,
then an alternative is `exception`, but just not `stop_iter` which is very
undescriptive.
Also, I'd support having three separate implementations for the `iter`
function, one for just sentinel, one for exception, and one for both, so
the iteration would be as quick as possible after the iterator was created.
Thanks,
Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140207/bea60ff1/attachment.html>
More information about the Python-ideas
mailing list