New submission from Ram Rachum:
See discussion:
https://groups.google.com/forum/#!searchin/python-ideas/iter/python-ideas/UCaNfAHkBlQ/5vX7JbpCxDkJ
`iter` has a very cool `sentinel` argument. I suggest an additional argument
`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, exception=IndexError)
I also suggest being able to pass multiple exceptions in a tuple to have any of
them trigger a `StopIteration`.
----------
components: Interpreter Core
messages: 211431
nosy: cool-RR, terry.reedy
priority: normal
severity: normal
status: open
title: Introduce exception argument to iter
type: enhancement
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20663>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com