[Python-checkins] CVS: python/dist/src/Lib/test test_generators.py,1.8,1.9
Tim Peters
tim_one@users.sourceforge.net
Mon, 25 Jun 2001 12:46:27 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv12643/python/dist/src/Lib/test
Modified Files:
test_generators.py
Log Message:
Teach the types module about generators. Thanks to James Althoff on the
Iterators list for bringing it up!
Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** test_generators.py 2001/06/25 01:30:12 1.8
--- test_generators.py 2001/06/25 19:46:25 1.9
***************
*** 368,371 ****
--- 368,391 ----
[1, 2, 3, 4]
5-combs of [1, 2, 3, 4]:
+
+ # From the Iterators list, about the types of these things.
+
+ >>> def g():
+ ... yield 1
+ ...
+ >>> type(g)
+ <type 'function'>
+ >>> i = g()
+ >>> type(i)
+ <type 'generator'>
+ >>> dir(i)
+ ['next']
+ >>> print i.next.__doc__
+ next() -- get the next value, or raise StopIteration
+ >>> iter(i) is i
+ 1
+ >>> import types
+ >>> isinstance(i, types.GeneratorType)
+ 1
"""