[Python-3000] Please re-add __cmp__ to python 3000
greg.ewing at canterbury.ac.nz
Wed Oct 31 06:22:06 CET 2007
Steven Bethard wrote:
> If a class defines only __cmp__, Python will do the appropriate
> dance to make <, >, ==, etc. work right. If a class defines only
> __eq__, __lt__, etc. Python will do the appropriate dance to make
> cmp() work right.
With a four-way __cmp__, I wouldn't actually mind if
the dance only worked one way, i.e. richcmp --> cmp.
In that world, the only reason to define separate
comparison operators would be if you were using them
for something radically different from normal
comparison. So defining __cmp__ could be defined as
the standard way to implement comparison operators
unless there's some reason you really can't do it
that way, in which case you just have to live with
cmp() not working on your type.
More information about the Python-3000