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
503f2935
Kaydet (Commit)
503f2935
authored
Ock 07, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clean up markup.
üst
3c403b23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
collections.rst
Doc/library/collections.rst
+5
-7
No files found.
Doc/library/collections.rst
Dosyayı görüntüle @
503f2935
...
...
@@ -458,7 +458,7 @@ three additional methods and one attribute.
>>> Point._make(t)
Point(x=11, y=22)
.. method::
some
namedtuple._asdict()
.. method:: namedtuple._asdict()
Return a new dict which maps field names to their corresponding values:
...
...
@@ -467,7 +467,7 @@ three additional methods and one attribute.
>>> p._asdict()
{'x': 11, 'y': 22}
.. method::
some
namedtuple._replace(kwargs)
.. method:: namedtuple._replace(kwargs)
Return a new instance of the named tuple replacing specified fields with new values:
...
...
@@ -480,7 +480,7 @@ three additional methods and one attribute.
>>> for partnum, record in inventory.items():
... inventory[partnum] = record._replace(price=newprices[partnum], updated=time.now())
.. attribute::
some
namedtuple._fields
.. attribute:: namedtuple._fields
Tuple of strings listing the field names. This is useful for introspection
and for creating new named tuple types from existing named tuples.
...
...
@@ -511,9 +511,7 @@ When casting a dictionary to a named tuple, use the double-star-operator [#]_::
Since a named tuple is a regular Python class, it is easy to add or change
functionality with a subclass. Here is how to add a calculated field and
a fixed-width print format:
::
a fixed-width print format::
>>> class Point(namedtuple('Point', 'x y')):
@property
...
...
@@ -528,7 +526,7 @@ a fixed-width print format:
Point(x=1.286, y=6.000, hypot=6.136)
Another use for subclassing is to replace performance critcal methods with
faster versions that bypass error-checking and localize variable access:
faster versions that bypass error-checking and localize variable access:
:
>>> class Point(namedtuple('Point', 'x y')):
_make = classmethod(tuple.__new__)
...
...
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