the cmp(xybuilt-in to compute its result both the __cmp__ method and the cmp built-in function are removed in python xuse the more specific methods instead we don' have space for an in-depth exploration of comparison methodsbut as quick introductionconsider the following class and test codeclass cdata 'spamdef __gt__(selfother)return self data other def __lt__(selfother)return self data other (print( 'ham'print( 'ham' and version true (runs __gt__false (runs __lt__when run under python or xthe prints at the end display the expected results noted in their commentsbecause the class' methods intercept and implement comparison expressions consult python' manuals and other reference resources for more details in this categoryfor example__lt__ is used for sorts in python xand as for binary expression operatorsthese methods can also return notimplemented for unsupported arguments the __cmp__ method in python in python onlythe __cmp__ method is used as fallback if more specific methods are not definedits integer result is used to evaluate the operator being run the following produces the same result as the prior section' code under xfor examplebut fails in because __cmp__ is no longer usedclass cdata 'spamdef __cmp__(selfother)return cmp(self dataother only __cmp__ not used in cmp not defined in (print( 'ham'print( 'ham'true (runs __cmp__false (runs __cmp__notice that this fails in because __cmp__ is no longer specialnot because the cmp built-in function is no longer present if we change the prior class to the following to try to simulate the cmp callthe code still works in but fails in xclass cdata 'spamdef __cmp__(selfother)return (self data other(self data other operator overloading