The Python Property Decorator
It is often considered best practice to create getters and setters for a class’s public properties. Many languages allow you to implement this in different ways, either by using a function (like person.getName()), or by using a language-specific get or set construct. In Python, it is done using @property. In this article I’ll be describing they Python property decorator, which you may have seen being used with the @decorator syntax: class Person(object): def __init__(self, first_name, last_name): self.first_name = first_name self.last_name […]
Read more