changeset: 86237:9f1e1da820fb branch: 2.7 parent: 86234:9aae58596349 user: Georg Brandl date: Sat Oct 12 18:44:13 2013 +0200 files: Doc/library/stdtypes.rst description: Closes #13905: mention rich-comparison methods in addition to __cmp__ when documenting how to make classes comparable and orderable. diff -r 9aae58596349 -r 9f1e1da820fb Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst Sat Oct 12 18:19:33 2013 +0200 +++ b/Doc/library/stdtypes.rst Sat Oct 12 18:44:13 2013 +0200 @@ -189,11 +189,22 @@ 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::

AltStyle によって変換されたページ (->オリジナル) /