Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3e7b1a04
Kaydet (Commit)
3e7b1a04
authored
Haz 25, 2001
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Teach the types module about generators. Thanks to James Althoff on the
Iterators list for bringing it up!
üst
ae1f65ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
libtypes.tex
Doc/lib/libtypes.tex
+6
-0
test_generators.py
Lib/test/test_generators.py
+20
-0
types.py
Lib/types.py
+5
-0
No files found.
Doc/lib/libtypes.tex
Dosyayı görüntüle @
3e7b1a04
...
...
@@ -83,6 +83,12 @@ The type of user-defined functions and lambdas.
An alternate name for
\code
{
FunctionType
}
.
\end{datadesc}
\begin{datadesc}
{
GeneratorType
}
The type of generator-iterator objects, produced by calling a
generator function.
\versionadded
{
2.2
}
\end{datadesc}
\begin{datadesc}
{
CodeType
}
The type for code objects such as returned by
\function
{
compile()
}
\bifuncindex
{
compile
}
.
...
...
Lib/test/test_generators.py
Dosyayı görüntüle @
3e7b1a04
...
...
@@ -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").
...
...
Lib/types.py
Dosyayı görüntüle @
3e7b1a04
...
...
@@ -32,6 +32,11 @@ try:
except
:
pass
def
g
():
yield
1
GeneratorType
=
type
(
g
())
del
g
class
_C
:
def
_m
(
self
):
pass
ClassType
=
type
(
_C
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment