I am new to Python and I just discovered the properties. It works just fine when I try it on a simple variable but I cannot make it work on a list. When executing the code below it will call two times the getter and not the setter. I know that in my example the property has no added value but it is to simplify.
class C:
def __init__(self):
self._x = [1, 2, 3]
@property
def x(self):
print("getter")
return self._x
@x.setter
def x(self, value):
print("setter")
self._x = value
c = C()
c.x[1] = 4
print(c.x[1])
Does anybody have an idea about what I'm doing wrong ?