Add keyword argument support to itertools.count().

This commit is contained in:
Raymond Hettinger 2009-02-14 04:21:49 +00:00
parent 8c20189ce4
commit 9e8dbbcdcd
3 changed files with 9 additions and 8 deletions

View file

@ -194,15 +194,16 @@ loops that truncate the stream.
.. versionadded:: 3.1
.. function:: count(n=0, step=1)
.. function:: count(start=0, step=1)
Make an iterator that returns evenly spaced values starting with *n*. Often
used as an argument to :func:`map` to generate consecutive data points.
Also, used with :func:`zip` to add sequence numbers. Equivalent to::
def count(n=0, step=1):
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) -> 3.5 3.0 4.5 ...
n = start
while True:
yield n
n += step