Next / Previous / Contents / Shipman's homepage

7.12. Pt.__cmp__(): Compare two points

The intent of this method is to determine whether two points coincide. The inequality cases are less useful, but we basically use x as the primary sort key and y as the secondary key.
# - - -   P t . _ _ c m p _ _

    def __cmp__(self, other):
        '''Compare two points.
        return cmp(self.xy(), other.xy())