summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-02-21 05:20:38 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-02-21 05:20:38 (GMT)
commitd36862cf78a280a5260f90a558cdac3d5f5897c1 (patch)
treecfe29ad1f92ca6a820565f14ad917e860640a422 /Doc
parent15cade0568f5028c9508c480e5d8fb9166e71f0e (diff)
downloadcpython-d36862cf78a280a5260f90a558cdac3d5f5897c1.zip
cpython-d36862cf78a280a5260f90a558cdac3d5f5897c1.tar.gz
cpython-d36862cf78a280a5260f90a558cdac3d5f5897c1.tar.bz2
Add itertools.izip_longest().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libitertools.tex27
1 files changed, 27 insertions, 0 deletions
diff --git a/Doc/lib/libitertools.tex b/Doc/lib/libitertools.tex
index 59fbd98..ac6028b 100644
--- a/Doc/lib/libitertools.tex
+++ b/Doc/lib/libitertools.tex
@@ -302,6 +302,33 @@ by functions or loops that truncate the stream.
don't care about trailing, unmatched values from the longer iterables.
\end{funcdesc}
+\begin{funcdesc}{izip_longest}{*iterables\optional{, fillvalue}}
+ Make an iterator that aggregates elements from each of the iterables.
+ If the iterables are of uneven length, missing values are filled-in
+ with \var{fillvalue}. Iteration continues until the longest iterable
+ is exhausted. Equivalent to:
+
+ \begin{verbatim}
+ def izip_longest(*args, **kwds):
+ fillvalue = kwds.get('fillvalue')
+ def sentinel(counter = ([fillvalue]*(len(args)-1)).pop):
+ yield counter() # yields the fillvalue, or raises IndexError
+ fillers = repeat(fillvalue)
+ iters = [chain(it, sentinel(), fillers) for it in args]
+ try:
+ for tup in izip(*iters):
+ yield tup
+ except IndexError:
+ pass
+ \end{verbatim}
+
+ If one of the iterables is potentially infinite, then the
+ \function{izip_longest()} function should be wrapped with something
+ that limits the number of calls (for example \function{islice()} or
+ \function{take()}).
+ \versionadded{2.6}
+\end{funcdesc}
+
\begin{funcdesc}{repeat}{object\optional{, times}}
Make an iterator that returns \var{object} over and over again.
Runs indefinitely unless the \var{times} argument is specified.