![](https://secure.gravatar.com/avatar/7b43f399ad17706bee01be8cd20165b0.jpg?s=120&d=mm&r=g)
Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv16102/Doc/lib Modified Files: libitertools.tex Log Message: Replace the window() example with pairwise() which demonstrates tee(). Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** libitertools.tex 24 Oct 2003 08:45:23 -0000 1.20 --- libitertools.tex 26 Oct 2003 15:34:50 -0000 1.21 *************** *** 406,419 **** return starmap(func, repeat(args, times)) ! def window(seq, n=2): ! "Returns a sliding window (of width n) over data from the iterable" ! " s -> (s0,s1,...s[n-1]), (s1,s2,...,sn), ... " ! it = iter(seq) ! result = tuple(islice(it, n)) ! if len(result) == n: ! yield result ! for elem in it: ! result = result[1:] + (elem,) ! yield result \end{verbatim} --- 406,413 ---- return starmap(func, repeat(args, times)) ! def pairwise(iterable): ! "s -> (s0,s1), (s1,s2), (s2, s3), ..." ! a, b = tee(iterable) ! return izip(a, islice(b, 1, None)) \end{verbatim}