[Python-ideas] Automatic total ordering

Raymond Hettinger python at rcn.com
Wed Oct 15 22:19:00 CEST 2008


From: "Guido van Rossum" <guido at python.org>
> I think we've done as much as I am comfortable with doing *by default*
> (i.e. when inheriting from object). The rest should be provided via
> mix-ins. But even those mix-ins should wait until 3.1.

Rather than a mix-in, my preference is for a class decorator that
is smart enough to propagate whatever underlying comparison is provided.
That way, you can choose to define any of __lt__, __le__, __gt__, or __ge__
to get all the rest.  We did something like this as a class exercise at PyUK.


Raymond



More information about the Python-ideas mailing list