‘Can’t set attribute’ with new-style properties in Python

The documentation says the following about using decorator form of property:

Be sure to give the additional functions the same name as the original property (x in this case.)

I have no idea why this is since if you use property as function to return an attribute the methods can be called whatever you like.

So you need to change your code to the following:

@x.setter
def x(self, value):
    'setting'
    self._x = value

Leave a Comment