Python 3 __cmp__ semantic change?

Terry Reedy tjreedy at udel.edu
Thu Nov 20 19:16:22 EST 2008


Johannes Bauer wrote:
> Steve Holden schrieb:
> 
>> If it's not present then it would be worth reporting it as a 3.0 bug -
>> there's still time to get it in, as the release isn't due until early
>> December.
> 
> Seems it was removed on purpose - I'm sure there was a good reason for
> that, but may I ask why? Instead of the sleek __cmp__ function I had
> earlier, I now have code like:
> 
> 
> def __lt__(self, other):
> 	return self.__cmp__(other) < 0
> 	
> def __le__(self, other):
> 	return self.__cmp__(other) < 0
> 	
> def __gt__(self, other):
> 	return self.__cmp__(other) > 0
> 
> def __ge__(self, other):
> 	return self.__cmp__(other) >= 0
> 
> Does anyone know the reason why __cmp__ was discarded?

See previous threads, including recent one about sorting.




More information about the Python-list mailing list