diff options
author | Raymond Hettinger <python@rcn.com> | 2009-02-12 06:28:27 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-02-12 06:28:27 (GMT) |
commit | 3072921d0e668e890da1312e0f47f3e7e4854329 (patch) | |
tree | b38f60c70b230878f3e993e9949f4b360313d4b2 /Doc/library/itertools.rst | |
parent | a9cab519656deda9fc3f500489bea1177d155858 (diff) | |
download | cpython-3072921d0e668e890da1312e0f47f3e7e4854329.zip cpython-3072921d0e668e890da1312e0f47f3e7e4854329.tar.gz cpython-3072921d0e668e890da1312e0f47f3e7e4854329.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 | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 8346587..fda3beb 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -178,7 +178,7 @@ loops that truncate the stream. The number of items returned is ``(n+r-1)! / r! / (n-1)!`` when ``n > 0``. - .. versionadded:: 2.7 + .. versionadded:: 3.1 .. function:: compress(data, selectors) @@ -191,22 +191,24 @@ loops that truncate the stream. # compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F return (d for d, s in zip(data, selectors) if s) - .. versionadded:: 2.7 + .. versionadded:: 3.1 -.. 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:`map` to - generate consecutive data points. Also, used with :func:`zip` to add sequence - numbers. Equivalent to:: + 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): + 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:: 3.1 + added *step* argument and allowed non-integer arguments. .. function:: cycle(iterable) |