[Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.23,
1.24
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Oct 26 10:34:52 EST 2003
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv16102/Lib/test
Modified Files:
test_itertools.py
Log Message:
Replace the window() example with pairwise() which demonstrates tee().
Index: test_itertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** test_itertools.py 26 Oct 2003 14:25:56 -0000 1.23
--- test_itertools.py 26 Oct 2003 15:34:50 -0000 1.24
***************
*** 624,637 ****
... 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
This is not part of the examples but it tests to make sure the definitions
--- 624,631 ----
... 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))
This is not part of the examples but it tests to make sure the definitions
***************
*** 682,689 ****
[0, 0, 0, 0, 0]
! >>> list(window('abc'))
! [('a', 'b'), ('b', 'c')]
! >>> list(window('abc',5))
[]
--- 676,686 ----
[0, 0, 0, 0, 0]
! >>> list(pairwise('abcd'))
! [('a', 'b'), ('b', 'c'), ('c', 'd')]
! >>> list(pairwise([]))
! []
!
! >>> list(pairwise('a'))
[]
More information about the Python-checkins
mailing list