[issue25193] itertools.accumlate should have an optional initializer argument

Alun Champion report at bugs.python.org
Sun Sep 20 10:46:40 CEST 2015


New submission from Alun Champion:

itertools.accumulate should have an initializer with the same semantics as functools.reduce.
These two functions are closely related, reduce only providing you the end result accumulate providing an iterator over all the intermediate results.
However, if you want all the intermediate results to this reduce:

    functools.reduce(operator.mul, range(1, 4), 10)

You currently need to do:

    itertools.accumulate(itertools.chain([10], range(1,4), operator.mul)

Adding an optional initialiser argument would avoid this.

----------
components: Library (Lib)
messages: 251155
nosy: Alun Champion
priority: normal
severity: normal
status: open
title: itertools.accumlate should have an optional initializer argument
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25193>
_______________________________________


More information about the Python-bugs-list mailing list