What are accessors, mutators, and @property?

Last updated 3 weeks, 4 days ago | 20 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.