Skip to content

Commit cf9a11a

Browse files
committed
Fixed test errors by implementing __getitem__ method for Vec2D
1 parent 0161017 commit cf9a11a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_turtle.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
try:
3737
import board
38-
except:
38+
except NotImplementedError:
3939
print("[adafruit-turtle.py]: Couldn't import board module.")
4040

4141
__version__ = "0.0.0+auto.0"
@@ -102,6 +102,9 @@ class Vec2D:
102102
def __new__(cls, x, y):
103103
return (x, y)
104104

105+
def __getitem__(self, index):
106+
return getattr(self, index)
107+
105108
def __add__(self, other):
106109
return Vec2D(self[0] + other[0], self[1] + other[1])
107110

0 commit comments

Comments
 (0)