[Python-checkins] r70265 - python/branches/py3k/Doc/library/itertools.rst

raymond.hettinger python-checkins at python.org
Mon Mar 9 12:55:26 CET 2009


Author: raymond.hettinger
Date: Mon Mar  9 12:55:25 2009
New Revision: 70265

Log:
Add consume() recipe to itertools docs.

Modified:
   python/branches/py3k/Doc/library/itertools.rst

Modified: python/branches/py3k/Doc/library/itertools.rst
==============================================================================
--- python/branches/py3k/Doc/library/itertools.rst	(original)
+++ python/branches/py3k/Doc/library/itertools.rst	Mon Mar  9 12:55:25 2009
@@ -615,6 +615,10 @@
        "Return function(0), function(1), ..."
        return map(function, count(start))
 
+   def consume(iterator, n):
+       "Advance the iterator n-steps ahead. If n is none, consume entirely."
+       collections.deque(islice(iterator, n), maxlen=0)
+
    def nth(iterable, n, default=None):
        "Returns the nth item or a default value"
        return next(islice(iterable, n, None), default)


More information about the Python-checkins mailing list