Kaydet (Commit) 01e4c117 authored tarafından Victor Stinner's avatar Victor Stinner

Merge 3.5

...@@ -1338,11 +1338,14 @@ Basic customization ...@@ -1338,11 +1338,14 @@ Basic customization
Called by built-in function :func:`hash` and for operations on members of Called by built-in function :func:`hash` and for operations on members of
hashed collections including :class:`set`, :class:`frozenset`, and hashed collections including :class:`set`, :class:`frozenset`, and
:class:`dict`. :meth:`__hash__` should return an integer. The only :class:`dict`. :meth:`__hash__` should return an integer. The only required
required property is that objects which compare equal have the same hash property is that objects which compare equal have the same hash value; it is
value; it is advised to somehow mix together (e.g. using exclusive or) the advised to mix together the hash values of the components of the object that
hash values for the components of the object that also play a part in also play a part in comparison of objects by packing them into a tuple and
comparison of objects. hashing the tuple. Example::
def __hash__(self):
return hash((self.name, self.nick, self.color))
.. note:: .. note::
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment