Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Raymond Hettinger
[Michael Foord] > Is there something you don't like about this one: http://code.activestate.com/recipes/576529/ [Mart Sõmermaa ] Yes -- it is not in the standard library. As I said, eventually all the 15,000 matches on Google Code need to update their code and copy that snippet to their uti

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Michael Foord
Mart Sõmermaa wrote: On Tue, Mar 10, 2009 at 3:57 PM, Michael Foord mailto:fuzzy...@voidspace.org.uk>> wrote: Is there something you don't like about this one: http://code.activestate.com/recipes/576529/ Yes -- it is not in the standard library. As I said, eventually all the 15,00

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Mart Sõmermaa
On Tue, Mar 10, 2009 at 3:57 PM, Michael Foord wrote: > Is there something you don't like about this one: > http://code.activestate.com/recipes/576529/ > Yes -- it is not in the standard library. As I said, eventually all the 15,000 matches on Google Code need to update their code and copy that s

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Michael Foord
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 method

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Raymond Hettinger
[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

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Michael Foord
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

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Raymond Hettinger
[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

Re: [Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Michael Foord
Hello Mart, This has been discussed before. Guido was against automatically filling in these methods based I think on the fact that this may not be what you want - worth searching the archives for. See here for a class decorator that provides all rich comparison methods for classes that only

[Python-Dev] Deprecated __cmp__ and total ordering

2009-03-10 Thread Mart Sõmermaa
__cmp__ used to provide a convenient way to make all ordering operators work by defining a single method. For better or worse, it's gone in 3.0. 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