Skip to content

Commit 67f742e

Browse files
authored
gh-72971: Clarify the special no-TypeError behavior for equality (#110729)
1 parent d1fd060 commit 67f742e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Doc/reference/datamodel.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,12 +1812,15 @@ Basic customization
18121812
rather, :meth:`__lt__` and :meth:`__gt__` are each other's reflection,
18131813
:meth:`__le__` and :meth:`__ge__` are each other's reflection, and
18141814
:meth:`__eq__` and :meth:`__ne__` are their own reflection.
1815-
If the operands are of different types, and right operand's type is
1815+
If the operands are of different types, and the right operand's type is
18161816
a direct or indirect subclass of the left operand's type,
18171817
the reflected method of the right operand has priority, otherwise
18181818
the left operand's method has priority. Virtual subclassing is
18191819
not considered.
18201820

1821+
When no appropriate method returns any value other than :data:`NotImplemented`, the
1822+
``==`` and ``!=`` operators will fall back to ``is`` and ``is not``, respectively.
1823+
18211824
.. method:: object.__hash__(self)
18221825

18231826
.. index::

0 commit comments

Comments
 (0)