]> granicus.if.org Git - python/commitdiff
Add a usage note
authorRaymond Hettinger <python@rcn.com>
Wed, 1 Feb 2012 16:52:44 +0000 (08:52 -0800)
committerRaymond Hettinger <python@rcn.com>
Wed, 1 Feb 2012 16:52:44 +0000 (08:52 -0800)
Doc/library/itertools.rst

index 36a391b4095e8f743d30e2444d4093bc9c77df72..21465e5721b208a85a22e7d34fd50814ef95c47d 100644 (file)
@@ -590,6 +590,11 @@ loops that truncate the stream.
               for i in xrange(times):
                   yield object
 
+   A common use for *repeat* is to supply a stream of constant values to *imap*
+   or *zip*::
+      >>> list(imap(pow, range(10), repeat(2)))
+      [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
 
 .. function:: starmap(function, iterable)