4 ms·
Very good article. Just to mention that Python does support getters and setters via the @property decorator. Instead of doing p._age to access the private attri
by RMPR 7y ago
Very good article.
Just to mention that Python does support getters and setters via the @property decorator. Instead of doing p._age to access the private attribute, you must add inside the Person class:
@property
def age(self):
return self._age
@age.setter
def age(self, value):
self._age = value
Then access the value of _age with p.age