diff python/moving.py @ 575:13df64a9ff9d

added function to access point class as 2D list
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 13 Aug 2014 10:51:16 -0400
parents e24eeb244698
children 0eff0471f9cb
line wrap: on
line diff
--- a/python/moving.py	Wed Aug 13 00:00:08 2014 -0400
+++ b/python/moving.py	Wed Aug 13 10:51:16 2014 -0400
@@ -179,6 +179,14 @@
 
     def __neg__(self):
         return Point(-self.x, -self.y)
+
+    def __getitem__(self, i):
+        if i == 0:
+            return self.x
+        elif i == 1:
+            return self.y
+        else:
+            raise IndexError()
     
     def orthogonal(self):
         return Point(self.y, -self.x)