diff options
author | Georg Brandl <georg@python.org> | 2013-10-12 16:44:13 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-10-12 16:44:13 (GMT) |
commit | 5b68d649920dd84515950a5a02ffdac4ec15c4a8 (patch) | |
tree | 64ad3afd2615d68fb26d21e0d134fcf435562e91 | |
parent | c2a9dc35c06b6aa57f9ab3c047f528bb1d549182 (diff) | |
download | cpython-5b68d649920dd84515950a5a02ffdac4ec15c4a8.zip cpython-5b68d649920dd84515950a5a02ffdac4ec15c4a8.tar.gz cpython-5b68d649920dd84515950a5a02ffdac4ec15c4a8.tar.bz2 |
Closes #13905: mention rich-comparison methods in addition to __cmp__ when documenting how to make classes comparable and orderable.
-rw-r--r-- | Doc/library/stdtypes.rst | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index cd7b683..1e6394b 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -189,11 +189,22 @@ such objects are ordered arbitrarily but consistently. The ``<``, ``<=``, ``>`` and ``>=`` operators will raise a :exc:`TypeError` exception when any operand is a complex number. -.. index:: single: __cmp__() (instance method) - -Instances of a class normally compare as non-equal unless the class defines the -:meth:`__cmp__` method. Refer to :ref:`customization`) for information on the -use of this method to effect object comparisons. +.. index:: + single: __cmp__() (instance method) + single: __eq__() (instance method) + single: __ne__() (instance method) + single: __lt__() (instance method) + single: __le__() (instance method) + single: __gt__() (instance method) + single: __ge__() (instance method) + +Non-identical instances of a class normally compare as non-equal unless the +class defines the :meth:`__eq__` method or the :meth:`__cmp__` method. + +Instances of a class cannot be ordered with respect to other instances of the +same class, or other types of object, unless the class defines either enough of +the rich comparison methods (:meth:`__lt__`, :meth:`__le__`, :meth:`__gt__`, and +:meth:`__ge__`) or the :meth:`__cmp__` method. .. impl-detail:: |