Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15b04eb

Browse files
committed
#20103: Rewrite description of itertools.accumulate().
Patch by Christian Hudon.
1 parent 42a17fa commit 15b04eb

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Doc/library/itertools.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,15 @@ loops that truncate the stream.
8787

8888
.. function:: accumulate(iterable[, func])
8989

90-
Make an iterator that returns accumulated sums. Elements may be any addable
91-
type including :class:`~decimal.Decimal` or :class:`~fractions.Fraction`.
92-
If the optional *func* argument is supplied, it should be a function of two
93-
arguments and it will be used instead of addition.
90+
Make an iterator that returns accumulated sums, or accumulated
91+
results of other binary functions (specified via the optional
92+
*func* argument). If *func* is supplied, it should be a function
93+
of two arguments. Elements of the input *iterable* may be any type
94+
that can be accepted as arguments to *func*. (For example, with
95+
the default operation of addition, elements may be any addable
96+
type including :class:`~decimal.Decimal` or
97+
:class:`~fractions.Fraction`.) If the input iterable is empty, the
98+
output iterable will also be empty.
9499

95100
Equivalent to::
96101

0 commit comments

Comments
 (0)