[Python-checkins] python/dist/src/Lib/test test_itertools.py,1.13,1.14

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Fri, 27 Jun 2003 22:44:38 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv19392/Lib/test

Modified Files:
	test_itertools.py 
Log Message:
Add take() to examples.  Tighten the islice() example

Index: test_itertools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** test_itertools.py	18 Jun 2003 19:25:37 -0000	1.13
--- test_itertools.py	28 Jun 2003 05:44:36 -0000	1.14
***************
*** 393,397 ****
  
  >>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
! >>> for name in islice(reportlines, 3, len(reportlines), 2):
  ...    print name.title()
  ...
--- 393,397 ----
  
  >>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
! >>> for name in islice(reportlines, 3, None, 2):
  ...    print name.title()
  ...
***************
*** 450,453 ****
--- 450,456 ----
  ...         yield result
  
+ >>> def take(n, seq):
+ ...     return list(islice(seq, n))
+ 
  This is not part of the examples but it tests to make sure the definitions
  perform as purported.
***************
*** 494,497 ****
--- 497,503 ----
  >>> dotproduct([1,2,3], [4,5,6])
  32
+ 
+ >>> take(10, count())
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  
  """