Skip to content

Commit 47f94f2

Browse files
authored
Merge pull request #1 from FoamyGuy/foamyguy_cpython_compat
CPython compatibility
2 parents 8c32679 + 12e4ec2 commit 47f94f2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

adafruit_turtle.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@
3232
import time
3333
import displayio
3434

35-
try:
36-
import board
37-
except NotImplementedError:
38-
print("[adafruit-turtle.py]: Couldn't import board module.")
39-
4035
__version__ = "0.0.0+auto.0"
4136
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_turtle.git"
4237

@@ -98,11 +93,11 @@ class Vec2D:
9893
# k*a and a*k multiplication with scalar
9994
# |a| absolute value of a
10095
# a.rotate(angle) rotation
101-
def __new__(cls, x, y):
102-
return (x, y)
96+
def __init__(self, x, y):
97+
self.values = (x, y)
10398

10499
def __getitem__(self, index):
105-
return getattr(self, index)
100+
return self.values[index]
106101

107102
def __add__(self, other):
108103
return Vec2D(self[0] + other[0], self[1] + other[1])
@@ -154,6 +149,9 @@ def __init__(self, display=None, scale=1):
154149
self._display = display
155150
else:
156151
try:
152+
# pylint: disable=import-outside-toplevel
153+
import board
154+
157155
self._display = board.DISPLAY
158156
except AttributeError as err:
159157
raise RuntimeError(
@@ -404,6 +402,7 @@ def goto(self, x1, y1=None):
404402

405403
setpos = goto
406404
setposition = goto
405+
407406
# pylint:enable=too-many-branches,too-many-statements
408407

409408
def setx(self, x):

0 commit comments

Comments
 (0)