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

Skip to content

Commit 2d93e6e

Browse files
committed
Update the itertools.accumulate() docs.
1 parent 240f112 commit 2d93e6e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Doc/library/itertools.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Iterator Arguments Results
4646
==================== ============================ ================================================= =============================================================
4747
Iterator Arguments Results Example
4848
==================== ============================ ================================================= =============================================================
49-
:func:`accumulate` p[, start=0] p0, p0+p1, p0+p1+p2, ... ``accumulate([1,2,3,4,5]) --> 1 3 6 10 15``
49+
:func:`accumulate` p p0, p0+p1, p0+p1+p2, ... ``accumulate([1,2,3,4,5]) --> 1 3 6 10 15``
5050
:func:`chain` p, q, ... p0, p1, ... plast, q0, q1, ... ``chain('ABC', 'DEF') --> A B C D E F``
5151
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
5252
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
@@ -84,11 +84,10 @@ The following module functions all construct and return iterators. Some provide
8484
streams of infinite length, so they should only be accessed by functions or
8585
loops that truncate the stream.
8686

87-
.. function:: accumulate(iterable, start=0)
87+
.. function:: accumulate(iterable)
8888

89-
Make an iterator that returns accumulated sums plus the value of the *start*
90-
parameter (which defaults to :const:`0`). Elements may be any addable type
91-
including :class:`Decimal` or :class:`Fraction`. Equivalent to::
89+
Make an iterator that returns accumulated sums. Elements may be any addable
90+
type including :class:`Decimal` or :class:`Fraction`. Equivalent to::
9291

9392
def accumulate(iterable):
9493
'Return running totals'

Lib/test/test_itertools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def test_accumulate(self):
6666
self.assertEqual(
6767
list(accumulate(map(typ, range(10)))),
6868
list(map(typ, [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])))
69+
self.assertEqual(list(accumulate('abc')), ['a', 'ab', 'abc']) # works with non-numeric
6970
self.assertEqual(list(accumulate([])), []) # empty iterable
7071
self.assertEqual(list(accumulate([7])), [7]) # iterable of length one
7172
self.assertRaises(TypeError, accumulate, range(10), 5) # too many args

0 commit comments

Comments
 (0)