[Tutor] line class

Christopher Spears cspears2002 at yahoo.com
Wed Jul 9 00:29:00 CEST 2008


I have been reading everyone's comments on my line class.  I have decided to implement some of the suggestions.  Someone suggested that I create a Point.__cmp__ method.  Here is what I have so far:

def __cmp__(self, other):
        if self.x == other.x and self.y == other.y:
	    return 0
	elif self.x < other.x and self.y < other.y:
	    return -1
	elif self.x > other.x and self.y > other.y:
	    return 1

Figuring out the results for the above situations was easy.  However, what should I do with the following situations:
self.x > other.x and self.y < other.y
self.x < other.x and self.y > other.y

Thanks.



      


More information about the Tutor mailing list