What is the @property decorator?

Python classes and OOP · Freshers and experienced

Model answer

It lets a method be accessed like an attribute, so you can add validation or computed values without changing how callers use the class: user.full_name. You can add a setter with @full_name.setter. It lets you start with a plain attribute and add logic later.

Learn this topic

Classes and Objects in Python: A Gentle Introduction in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions