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)
--
The dead increasingly dominate and strangle both the living and the
not-yet born. Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/N4ADISQDR6NUWA37BYIQHZ3EPBYMVODP/
Code of Conduct: http://python.org/psf/codeofconduct/