Skip to content

Commit b32fb6c

Browse files
csabellaMariatta
authored andcommitted
bpo-30538: Update count() in Functional Programming HOWTO (GH-1919) (GH-1944)
* bpo-30538: Update count() in Functional HOWTO * bpo-30538: Update enumerate() arguments in Functional HOWTO (cherry picked from commit 9be4ff3)
1 parent 1f04b90 commit b32fb6c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Doc/howto/functional.rst

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,9 @@ This can also be written as a list comprehension:
653653
[0, 2, 4, 6, 8]
654654

655655

656-
:func:`enumerate(iter) <enumerate>` counts off the elements in the iterable,
657-
returning 2-tuples containing the count and each element. ::
656+
:func:`enumerate(iter, start=0) <enumerate>` counts off the elements in the
657+
iterable returning 2-tuples containing the count (from *start*) and
658+
each element. ::
658659

659660
>>> for item in enumerate(['subject', 'verb', 'object']):
660661
... print(item)
@@ -747,14 +748,16 @@ The module's functions fall into a few broad classes:
747748
Creating new iterators
748749
----------------------
749750

750-
:func:`itertools.count(n) <itertools.count>` returns an infinite stream of
751-
integers, increasing by 1 each time. You can optionally supply the starting
752-
number, which defaults to 0::
751+
:func:`itertools.count(start, step) <itertools.count>` returns an infinite
752+
stream of evenly spaced values. You can optionally supply the starting number,
753+
which defaults to 0, and the interval between numbers, which defaults to 1::
753754

754755
itertools.count() =>
755756
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
756757
itertools.count(10) =>
757758
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
759+
itertools.count(10, 5) =>
760+
10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ...
758761

759762
:func:`itertools.cycle(iter) <itertools.cycle>` saves a copy of the contents of
760763
a provided iterable and returns a new iterator that returns its elements from
@@ -1060,10 +1063,10 @@ write the obvious :keyword:`for` loop::
10601063
for i in [1,2,3]:
10611064
product *= i
10621065

1063-
A related function is `itertools.accumulate(iterable, func=operator.add) <itertools.accumulate`.
1064-
It performs the same calculation, but instead of returning only the
1065-
final result, :func:`accumulate` returns an iterator that also yields
1066-
each partial result::
1066+
A related function is :func:`itertools.accumulate(iterable, func=operator.add)
1067+
<itertools.accumulate>`. It performs the same calculation, but instead of
1068+
returning only the final result, :func:`accumulate` returns an iterator that
1069+
also yields each partial result::
10671070

10681071
itertools.accumulate([1,2,3,4,5]) =>
10691072
1, 3, 6, 10, 15
@@ -1235,6 +1238,8 @@ Python documentation
12351238

12361239
Documentation for the :mod:`itertools` module.
12371240

1241+
Documentation for the :mod:`functools` module.
1242+
12381243
Documentation for the :mod:`operator` module.
12391244

12401245
:pep:`289`: "Generator Expressions"

0 commit comments

Comments
 (0)