If I understand your problem correctly, you need something like:
>>> class A(int): ... def __cmp__(self, other): ... return super(A, self).__cmp__(A(other))
Update
As for the 2.x cpython source, you can find the reason for this result in typeobject.c in the wrap_cmpfunc function, which actually checks two things: this comparison function is func and other is a subtype for self .
if (Py_TYPE(other)->tp_compare != func && !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) {
source share