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

6.4. Color.__cmp__(): Compare two colors

This method implements the usual Python comparison function. It can be used to test two colors for equality. The definition of inequality is pretty arbitary, so we will just use their #RRGGBB color names to do the comparison.

huey
# - - -   C o l o r . _ _ c m p _ _

    def __cmp__ ( self, other ):
        """Compare two colors."""
        return  cmp ( str(self), str(other) )