Skip to content

Commit 42568ff

Browse files
committed
Fixed Vec2D constructor for use with CPython
1 parent 6e11fb7 commit 42568ff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

adafruit_turtle.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ class Vec2D(tuple):
8989
May be useful for turtle graphics programs also.
9090
Derived from tuple, so a vector is a tuple!
9191
"""
92+
def __new__(cls, x, y):
93+
self = super().__new__(cls, (x, y))
94+
return self
9295

9396
# Provides (for a, b vectors, k number):
9497
# a+b vector addition
@@ -97,8 +100,8 @@ class Vec2D(tuple):
97100
# k*a and a*k multiplication with scalar
98101
# |a| absolute value of a
99102
# a.rotate(angle) rotation
100-
def __init__(self, x, y):
101-
super().__init__((x, y))
103+
# def __init__(self, x, y):
104+
# super().__init__((x, y))
102105

103106
def __add__(self, other):
104107
return Vec2D(self[0] + other[0], self[1] + other[1])

0 commit comments

Comments
 (0)