diff options
author | Raymond Hettinger <python@rcn.com> | 2009-02-12 05:39:46 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-02-12 05:39:46 (GMT) |
commit | 31c769ca89ee5f4fdd7ed7e462fa143ed979edee (patch) | |
tree | 562dcde280acb5c59d94371981ca514888ea79c1 /Doc/library/itertools.rst | |
parent | 4bb96feb60b80b580706e3a2c67db856382a530f (diff) | |
download | cpython-31c769ca89ee5f4fdd7ed7e462fa143ed979edee.zip cpython-31c769ca89ee5f4fdd7ed7e462fa143ed979edee.tar.gz cpython-31c769ca89ee5f4fdd7ed7e462fa143ed979edee.tar.bz2 |
Issue 5032: added a step argument to itertools.count() and allowed non-integer arguments.
Diffstat (limited to 'Doc/library/itertools.rst')
-rw-r--r-- | Doc/library/itertools.rst | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 240baf0..4dfc083 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -200,20 +200,23 @@ loops that truncate the stream. .. versionadded:: 2.7 -.. function:: count([n]) +.. function:: count(n=0, step=1) - Make an iterator that returns consecutive integers starting with *n*. If not - specified *n* defaults to zero. Often used as an argument to :func:`imap` to - generate consecutive data points. Also, used with :func:`izip` to add sequence - numbers. Equivalent to:: + Make an iterator that returns evenly spaced values starting with *n*. Often + used as an argument to :func:`imap` to generate consecutive data points. + Also, used with :func:`izip` to add sequence numbers. Equivalent to:: - def count(n=0): + def count(n=0, step=1): # count(10) --> 10 11 12 13 14 ... + # count(2.5, 0.5) -> 3.5 3.0 4.5 ... while True: yield n - n += 1 + n += step + .. versionchanged:: 2.7 + added *step* argument and allowed non-integer arguments. + .. function:: cycle(iterable) Make an iterator returning elements from the iterable and saving a copy of each. |