mirror of
https://github.com/python/cpython.git
synced 2025-12-09 18:48:05 +00:00
Add keyword argument support to itertools.count().
This commit is contained in:
parent
8c20189ce4
commit
9e8dbbcdcd
3 changed files with 9 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue