Skip to content

Commit aac56ac

Browse files
committed
Point is inherits from named tuple:
1 parent 922598f commit aac56ac

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

point.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import math
1+
from collections import namedtuple
22

3-
class Point:
4-
__slots__ = 'x', 'y'
3+
import math
54

6-
def __init__(self, x, y):
7-
self.x = x
8-
self.y = y
5+
class Point(namedtuple('Point', ['x', 'y'])):
6+
__slots__ = ()
97

108
def __add__(self, other):
119
return Point(self.x + other.x, self.y + other.y)

0 commit comments

Comments
 (0)