What are accessors, mutators, and @property?

Last updated 3 years, 6 months ago | 1533 views 75     5

Tags:- Python

Python | accessors, mutators, and @property

What we call getters and setters in languages like Java, we term accessors and mutators in Python. In Java, if we have a user-defined class with the property ‘x’, we have methods like getX() and setX().

In Python, we have @property, which is syntactic sugar for property(). This lets us get and set variables without compromising on the conventions.