The issue here is with the way you’ve defined the setter method. In Python, when using @property and @x.setter decorators, the setter method must be named exactly the same as the property itself, not with a different name like set_x
class C(object):
def __init__(self):
self._x = 0
@property
def x(self):
print('getting')
return self._x
@x.setter
def x(self, value): # The setter method should also be named 'x'
print('setting')
self._x = value
if __name__ == '__main__':
c = C()
print(c.x)
c.x = 10
print(c.x)
This approach will allow you to access and modify x using c.x while controlling the behavior with custom print statements.