File tree 3 files changed +31
-0
lines changed 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,12 @@ \section{\module{types} ---
83
83
An alternate name for \code {FunctionType}.
84
84
\end {datadesc }
85
85
86
+ \begin {datadesc }{GeneratorType}
87
+ The type of generator-iterator objects, produced by calling a
88
+ generator function.
89
+ \versionadded {2.2}
90
+ \end {datadesc }
91
+
86
92
\begin {datadesc }{CodeType}
87
93
The type for code objects such as returned by
88
94
\function {compile()}\bifuncindex {compile}.
Original file line number Diff line number Diff line change 367
367
4-combs of [1, 2, 3, 4]:
368
368
[1, 2, 3, 4]
369
369
5-combs of [1, 2, 3, 4]:
370
+
371
+ # From the Iterators list, about the types of these things.
372
+
373
+ >>> def g():
374
+ ... yield 1
375
+ ...
376
+ >>> type(g)
377
+ <type 'function'>
378
+ >>> i = g()
379
+ >>> type(i)
380
+ <type 'generator'>
381
+ >>> dir(i)
382
+ ['next']
383
+ >>> print i.next.__doc__
384
+ next() -- get the next value, or raise StopIteration
385
<
BD1A
/td>+ >>> iter(i) is i
386
+ 1
387
+ >>> import types
388
+ >>> isinstance(i, types.GeneratorType)
389
+ 1
370
390
"""
371
391
372
392
# Fun tests (for sufficiently warped notions of "fun").
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ def _f(): pass
32
32
except :
33
33
pass
34
34
35
+ def g ():
36
+ yield 1
37
+ GeneratorType = type (g ())
38
+ del g
39
+
35
40
class _C :
36
41
def _m (self ): pass
37
42
ClassType = type (_C )
You can’t perform that action at this time.
0 commit comments