I have a Vec2 with the following implementation:
class Vec2:
def __init__(self, x, y):
self.x, self.y = x, y
def __eq__(self, other: Vec2):
return self.x == other.x and self.y == other.y
def __hash__(self):
return hash(self.xy())
def __str__(self):
return f"({self.x}, {self.y})"
def __repr__(self):
return str(self)
def xy(self):
return self.x, self.y
And I'm getting unexpected behavior when I interact with sets:
pos = Vec2(1, 1)
print(pos)
print(set(pos))
``` I expect
(1, 1)
{(1, 1)}
(1, 1)
{1}