summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generators.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-06-25 19:46:25 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-06-25 19:46:25 (GMT)
commit3e7b1a04a0fe02098ffc03b5c0fc6546a5f7d2d1 (patch)
tree1b79b6897c94e6914beb1f86e59c40a2ec9a056d /Lib/test/test_generators.py
parentae1f65ff825f72f3972e503036966e206f5b39fa (diff)
downloadcpython-3e7b1a04a0fe02098ffc03b5c0fc6546a5f7d2d1.zip
cpython-3e7b1a04a0fe02098ffc03b5c0fc6546a5f7d2d1.tar.gz
cpython-3e7b1a04a0fe02098ffc03b5c0fc6546a5f7d2d1.tar.bz2
Teach the types module about generators. Thanks to James Althoff on the
Iterators list for bringing it up!
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r--Lib/test/test_generators.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index e0d6cfa..884cbc0 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -367,6 +367,26 @@ Next one was posted to c.l.py.
4-combs of [1, 2, 3, 4]:
[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
"""
# Fun tests (for sufficiently warped notions of "fun").