Next / Previous / Contents / TCC Help System / NM Tech homepage

26.3.6. __cmp__(): Generalized comparison

The purpose of this special method is to implement comparison operations between instances. It will be called in these situations:

The calling sequence is:

    def __cmp__(self, other):
        ...

The convention for return values is the same one described in Section 20.8, “cmp(): Compare two values”: negative if self precedes other, positive if other precedes self, zero if they are considered equal.