2 ms·
Understanding the Underscore( _) in Python
- RMPR 7y agoVery 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