[Python-ideas] sentinel_exception argument to `iter`

Ram Rachum ram.rachum at gmail.com
Fri Feb 7 01:10:02 CET 2014


Hi,

This time I'm posting on the right list :) Sorry for the mistake in the 
last thread.

`iter` has a very cool `sentinel` argument. I suggest an additional 
argument `sentinel_exception`; when it's supplied, instead of waiting for a 
sentinel value, we wait for a sentinel exception to be raised, and then the 
iteration is finished.

This'll be useful to construct things like this: 

    my_iterator = iter(my_deque.popleft, IndexError)

What do you think? 



Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140206/468c2f37/attachment.html>


More information about the Python-ideas mailing list