[Python-ideas] sentinel_exception argument to `iter`

Ram Rachum ram at rachum.com
Fri Feb 7 01:17:43 CET 2014


Looks like someone needs to read the `iter` docs :)


On Fri, Feb 7, 2014 at 2:14 AM, Yury Selivanov <yselivanov.ml at gmail.com>wrote:

>
> On 2/6/2014, 7:10 PM, Ram Rachum wrote:
>
>> 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)
>>
>>  Before starting discussion about the new parameter:
> how passing 'my_deque.popleft' is supposed to work?
>
> Yury
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> --- You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/python-ideas/UCaNfAHkBlQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140207/c7ad529c/attachment.html>


More information about the Python-ideas mailing list