def whereis(point):
match point: case MovingPoint(0, 0): print("Origin") case MovingPoint(0, y): print(f"Y={y}") case MovingPoint(x, 0): print(f"X={x}") case MovingPoint(1, 1): print("Diagonal at units")
case MovingPoint():
print("Somewhere else") case _: print("Not a point")
What is the expected/intended behavior or this kind of point. Both "What matches?" and "What is the value of point.x and point.y afterwards?"
class MovingPoint: def __init__(self, x, y): self._x = x self._y = y
@property def x(self): x = self._x self._x +=1 return x
@property def y(self): y = self._y self._y += 1 return y
point = MovingPoint(0, 0) whereis(point)