views:

59

answers:

1

If I have class A that defines __cmp__, and class B that extends class A, it seems like I have to redefine __cmp__ in class B. Is this correct?

Is there a better workaround than implementing a method "cmp" in class A and calling it from the separate implementations of __cmp__ in class A and class B?

Thanks, -aj


UPDATE: The issue seems to be my lack of Python 3 exposure. As I read it, __cmp__ should no longer be used: http://docs.python.org/dev/3.0/whatsnew/3.0.html#ordering-comparisons

Instead, I've re-implemented my classes using the new ordering comparison operators: http://docs.python.org/dev/3.0/reference/datamodel.html#object.%5F%5Flt%5F%5F

+1  A: 

Assuming you have a class called "A", and that class has a definition for __ cmp __.

And let's assume you extend class A:

class B(A):

So to retrieve __ cmp __ from class A from within class B one would use:

A.__cmp__ from within class B

Is my guess.

Sev