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
e850c466
Kaydet (Commit)
e850c466
authored
Ock 10, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clarify how to add a field to a named tuple.
üst
e1655088
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
1 deletion
+4
-1
collections.rst
Doc/library/collections.rst
+1
-1
collections.py
Lib/collections.py
+3
-0
No files found.
Doc/library/collections.rst
Dosyayı görüntüle @
e850c466
...
...
@@ -538,7 +538,7 @@ faster versions that bypass error-checking and that localize variable access::
Subclassing is not useful for adding new, stored fields. Instead, simply
create a new named tuple type from the :attr:`_fields` attribute::
>>> P
ixel = namedtuple('Pixel', Point._fields + Color._fields
)
>>> P
oint3D = namedtuple('Point3D', Point._fields + ('z',)
)
Default values can be implemented by using :meth:`_replace` to
customize a prototype instance::
...
...
Lib/collections.py
Dosyayı görüntüle @
e850c466
...
...
@@ -137,6 +137,9 @@ if __name__ == '__main__':
print
Point
(
11
,
22
)
.
_replace
(
x
=
100
)
Point3D
=
namedtuple
(
'Point3D'
,
Point
.
_fields
+
(
'z'
,))
print
Point3D
.
__doc__
import
doctest
TestResults
=
namedtuple
(
'TestResults'
,
'failed attempted'
)
print
TestResults
(
*
doctest
.
testmod
())
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