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
82358691
Kaydet (Commit)
82358691
authored
Agu 31, 2008
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 2235: document the ability to block inheritance of __hash__ in the language reference
üst
4d028570
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
datamodel.rst
Doc/reference/datamodel.rst
+18
-2
No files found.
Doc/reference/datamodel.rst
Dosyayı görüntüle @
82358691
...
...
@@ -1382,13 +1382,29 @@ Basic customization
be in the wrong hash bucket).
User-defined classes have :meth:`__cmp__` and :meth:`__hash__` methods
by default; with them, all objects compare unequal and ``x.__hash__()``
returns ``id(x)``.
by default; with them, all objects compare unequal (except with themselves)
and ``x.__hash__()`` returns ``id(x)``.
Classes which inherit a :meth:`__hash__` method from a parent class but
change the meaning of :meth:`__cmp__` or :meth:`__eq__` such that the hash
value returned is no longer appropriate (e.g. by switching to a value-based
concept of equality instead of the default identity based equality) can
explicitly flag themselves as being unhashable by setting
``__hash__ = None`` in the class definition. Doing so means that not only
will instances of the class raise an appropriate :exc:`TypeError` when
a program attempts to retrieve their hash value, but they will also be
correctly identified as unhashable when checking
``isinstance(obj, collections.Hashable)`` (unlike classes which define
their own :meth:`__hash__` to explicitly raise :exc:`TypeError`).
.. versionchanged:: 2.5
:meth:`__hash__` may now also return a long integer object; the 32-bit
integer is then derived from the hash of that object.
.. versionchanged:: 2.6
:attr:`__hash__` may now be set to :const:`None` to explicitly flag
instances of a class as unhashable.
.. method:: object.__nonzero__(self)
...
...
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