Skip to content

Commit b7b4386

Browse files
authored
Merge pull request #31 from shulltronics/cpython-compatibility
CPython compatibility fix
2 parents 9f23b46 + 47f94f2 commit b7b4386

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

adafruit_turtle.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import gc
3131
import math
3232
import time
33-
import board
3433
import displayio
3534

3635
__version__ = "0.0.0+auto.0"
@@ -80,7 +79,7 @@ def __init__(self):
8079
pass
8180

8281

83-
class Vec2D(tuple):
82+
class Vec2D:
8483
"""A 2 dimensional vector class, used as a helper class
8584
for implementing turtle graphics.
8685
May be useful for turtle graphics programs also.
@@ -95,7 +94,10 @@ class Vec2D(tuple):
9594
# |a| absolute value of a
9695
# a.rotate(angle) rotation
9796
def __init__(self, x, y):
98-
super().__init__((x, y))
97+
self.values = (x, y)
98+
99+
def __getitem__(self, index):
100+
return self.values[index]
99101

100102
def __add__(self, other):
101103
return Vec2D(self[0] + other[0], self[1] + other[1])
@@ -147,6 +149,9 @@ def __init__(self, display=None, scale=1):
147149
self._display = display
148150
else:
149151
try:
152+
# pylint: disable=import-outside-toplevel
153+
import board
154+
150155
self._display = board.DISPLAY
151156
except AttributeError as err:
152157
raise RuntimeError(
@@ -397,6 +402,7 @@ def goto(self, x1, y1=None):
397402

398403
setpos = goto
399404
setposition = goto
405+
400406
# pylint:enable=too-many-branches,too-many-statements
401407

402408
def setx(self, x):

0 commit comments

Comments
 (0)