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
65ea9bd8
Kaydet (Commit)
65ea9bd8
authored
Eyl 05, 2007
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1684991: explain __special__ lookup semantics.
üst
08898b4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
datamodel.rst
Doc/reference/datamodel.rst
+14
-0
No files found.
Doc/reference/datamodel.rst
Dosyayı görüntüle @
65ea9bd8
...
@@ -1060,6 +1060,20 @@ raise an exception when no appropriate method is defined.
...
@@ -1060,6 +1060,20 @@ raise an exception when no appropriate method is defined.
.. XXX above translation is not correct for new-style classes!
.. XXX above translation is not correct for new-style classes!
Special methods are only guaranteed to work if defined in an object's class, not
in the object's instance dictionary. That explains why this won't work::
>>> class C:
... pass
...
>>> c = C()
>>> c.__len__ = lambda: 5
>>> len(c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object of type 'C' has no len()
When implementing a class that emulates any built-in type, it is important that
When implementing a class that emulates any built-in type, it is important that
the emulation only be implemented to the degree that it makes sense for the
the emulation only be implemented to the degree that it makes sense for the
object being modelled. For example, some sequences may work well with retrieval
object being modelled. For example, some sequences may work well with retrieval
...
...
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