I'm confused with how attribute variables are behaving in my class when using the property decorator.
See this example:
class Example:
def __init__(self, x):
self.x = x
@property
def x(self):
return self.__x
@x.setter
def x(self, x):
self.__x = x
This works fine, but how? The variable inside the setter property (self.__x) has not been "defined" in the constructor, so how can it be assigned a value?
Other stuff also works, for example, take the same class defined above and add a new member function to it:
def set_val_x(self):
self.__x = 8765
Again, using this function actually works, similar to the property.setter (but it's not using the property decorator).