[Python-ideas] Map and filter should also convert StopIteration to RuntimeError

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Dec 12 22:24:21 CET 2014


On Fri, Dec 12, 2014 at 4:14 PM, Terry Reedy <tjreedy at udel.edu> wrote:

> I propose that map.__next__ convert StopIteration raised by func to
> RuntimeError


Aren't we stepping on a slippery slope here?  What about say

>>> def f(x, y):
...     if x > 2:
...         raise StopIteration
...     return x + y
...
>>> import itertools
>>> itertools.accumulate(range(10), f)
<itertools.accumulate object at 0x10acc0fc8>
>>> list(_)
[0, 1, 3]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141212/3babfacb/attachment.html>


More information about the Python-ideas mailing list