I'm writing a Python class, and it I'm using the @property
decorator to create properties for the class.
I haven't found much in the documentation about this decorator, but from what I can gather from Stack Overflow and the instructions in my Python linter: in its entirety, a property created with the property decorator can take on the form definition, getter, setter, deleter, as shown here:
@property
def name(self):
return self.__name
@name.getter
def name(self):
return self.__name
@name.setter
def name(self, value):
self.__name=value
@name.deleter
def name(self):
del self.__name
I'm not entirely sure what the very first block is for. The code inside it is the exact same as the getter
function.
What is the first block for; how is it different from the getter
block, and if it is not, can I remove either one of them?