Next / Previous / Contents / Shipman's homepage

57. Slot.__cmp__(): How to compare two slots

When comparing two slots, a slot from a higher row comes before a slot from a lower row. If they are in the same row, the one on the left comes first. If both slots start in the same cell, the horizontal slot comes before the vertical slot.

# - - -   S l o t . _ _ c m p _ _

    def __cmp__ ( self, other ):
        '''Compare two slots by position.
        return cmp ( (self.origin, self.isV),
                     (other.origin, other.isV) )