0Pricing
Python Academy · Lesson

The @property Decorator

Use property for getters, setters, and deleters.

Introduction

@property turns a method into a readable attribute. @setter and @deleter complete the controlled access pattern.

Why @property?

Instead of getX()/setX() Java-style, Python uses @property. Access looks like an attribute: obj.value, not obj.get_value().
class Circle:
    def __init__(self, r): self._r = r
    @property
    def radius(self): return self._r
c = Circle(5)
print(c.radius)  # no ()

All lessons in this course

  1. Functions as First-Class Objects
  2. Writing Custom Decorators
  3. The @property Decorator
  4. @classmethod and @staticmethod
← Back to Python Academy