Permalink
Browse files

Define equality and disequality for Boxes

  • Loading branch information...
1 parent ee44ce5 commit 6afc8e1c51b2249011950644a24669c2a04fe731 @szabba committed Dec 14, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/boxes.py
View
@@ -53,6 +53,17 @@ def __contains__(self, point):
return (self.x <= x_p <= self.x + self.w and
self.y <= y_p <= self.y + self.h)
+ def __eq__(self, other):
+
+ return (self.x == other.x and
+ self.y == other.y and
+ self.w == other.w and
+ self.h == other.h)
+
+ def __ne__(self, other):
+
+ return not self == other
+
def __str__(self):
return "Box(%(x)d, %(y)d, %(w)d, %(h)d)" % self.__dict__

0 comments on commit 6afc8e1

Please sign in to comment.