[issue5479] Add an easy way to provide total ordering now that __cmp__ is deprecated/gone

Mart Sõmermaa report at bugs.python.org
Sat Mar 14 09:44:15 CET 2009


Mart Sõmermaa <mrts at mrts.pri.ee> added the comment:

> This is the 2.6 version. What about the 3.0 version in
> http://docs.python.org/3.0/reference/datamodel.html#object.__lt__
> needs to be updated?

When functools.total_ordering (whether it lands in functools is open)
lands that section should be amended in the lines of the following:

"There are no implied relationships among the comparison operators. The
truth of x==y does not imply that x!=y is false. Accordingly, when
defining __eq__(), one should also define __ne__() so that the operators
will behave as expected.

However, given a class defining one or more ordering methods,
`functools.total_ordering`_ class decorator can be used to fill in the
rest. Please see the documentation of `functools.total_ordering`_ for
further details."

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5479>
_______________________________________


More information about the Python-bugs-list mailing list