@@ -653,8 +653,9 @@ This can also be written as a list comprehension:
653
653
[0, 2, 4, 6, 8]
654
654
655
655
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. ::
658
659
659
660
>>> for item in enumerate(['subject', 'verb', 'object']):
660
661
... print(item)
@@ -747,14 +748,16 @@ The module's functions fall into a few broad classes:
747
748
Creating new iterators
748
749
----------------------
749
750
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 ::
753
754
754
755
itertools.count() =>
755
756
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
756
757
itertools.count(10) =>
757
758
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, ...
758
761
759
762
:func: `itertools.cycle(iter) <itertools.cycle> ` saves a copy of the contents of
760
763
a provided iterable and returns a new iterator that returns its elements from
@@ -1060,10 +1063,10 @@ write the obvious :keyword:`for` loop::
1060
1063
for i in [1,2,3]:
1061
1064
product *= i
1062
1065
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::
1067
1070
1068
1071
itertools.accumulate([1,2,3,4,5]) =>
1069
1072
1, 3, 6, 10, 15
@@ -1235,6 +1238,8 @@ Python documentation
1235
1238
1236
1239
Documentation for the :mod: `itertools ` module.
1237
1240
1241
+ Documentation for the :mod: `functools ` module.
1242
+
1238
1243
Documentation for the :mod: `operator ` module.
1239
1244
1240
1245
:pep: `289 `: "Generator Expressions"
0 commit comments