I am exploring decorators in Python, and as a person who came to Python from other languages, I am a bit confused about the purpose of @property
and its @xxx.setter
brother. In Java and C++ get_xxx()
and set_xxx()
are usually the way to organize encapsulation. In Python we have these two decorators, which require specific syntax, and name matching in order to work. How is @property
better than get-set
methods?
I have checked this post and still, what are the advantages of @property
besides the availability of the +=
operator?