[Python-Dev] Deprecated __cmp__ and total ordering
Michael Foord
fuzzyman at voidspace.org.uk
Tue Mar 10 14:57:15 CET 2009
Raymond Hettinger wrote:
>
> [Mart Sõmermaa]
>> To provide total ordering without __cmp__ one has to implement all of
>> __lt__, __gt__, __le__, __ge__, __eq__ and __ne__. However, in all
>> but a few cases it suffices only to provide a "real" implementation for
>> e.g. __lt__ and define all the other methods in terms of it as follows:
>
> FWIW, I'm working on a solution for the problem using class decorators.
> The idea is that it would scan a class and fill-in missing methods based
> on the ones already there. That way, any one of the four ordering
> relations can be provided as a starting point and we won't have to
> annoint one like __lt__ as the one true underlying method.
>
> When it's ready, I'll bring it to python-dev for discussion.
Is there something you don't like about this one:
http://code.activestate.com/recipes/576529/
Michael
>
>
> Raymond
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
>
--
http://www.ironpythoninaction.com/
More information about the Python-Dev
mailing list