0

Python getters and setters

There are important right

4th Feb 2020, 11:25 AM
Pame
Pame - avatar
2 Answers
+ 2
OOP in Python is really simplified compared to other languages, the encapsulation is much more loosely implemented, you can't make truly private variables. That's why getters and setters are not commonly used. If you want to add extra validation or special logic to getting/setting variables, then the best practice (the pythonic way) is to use property decorators above the specific functions: @property @varname.setter https://www.sololearn.com/learn/Python/2472/
4th Feb 2020, 3:25 PM
Tibor Santa
Tibor Santa - avatar