I am trying to create a point class that defines a coordinate property. However, it does not behave as I expected, and I cannot understand why.
class Point: def __init__(self, coord=None): self.x = coord[0] self.y = coord[1] @property def coordinate(self): return (self.x, self.y) @coordinate.setter def coordinate(self, value): self.x = value[0] self.y = value[1] p = Point((0,0)) p.coordinate = (1,2) >>> px 0 >>> py 0 >>> p.coordinate (1, 2)
It seems that px and py are not installing for some reason, although the installer "should" set these values. Does anyone know why this is?
python
cdwilson
source share