diff -r a5c8bf5d1d5b Doc/reference/datamodel.rst --- a/Doc/reference/datamodel.rst Wed Apr 18 18:59:56 2012 +0200 +++ b/Doc/reference/datamodel.rst Wed Apr 18 11:02:08 2012 -0700 @@ -1260,22 +1260,20 @@ 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:`__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 + Classes which change the meaning of :meth:`__eq__` (thus losing automatic + delegation to the parent class' :meth:``__hash__``) can explicitly flag + themselves as being unhashable by setting :meth:``__hash__ = None`` in the + class definition (which is otherwise done implicity). Having + :meth:``__hash__`` set to :const:``None``, either explicitly or implicitly, + 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`). If a class that overrides :meth:`__eq__` needs to retain the implementation of :meth:`__hash__` from a parent class, the interpreter must be told this - explicitly by setting ``__hash__ = .__hash__``. Otherwise the - inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__` - had been explicitly set to :const:`None`. + explicitly by setting ``__hash__ = .__hash__``. .. note::