@property
corebeginner@property turns a method into something read like a plain attribute — obj.value instead of obj.value(). The method still runs every time the attribute is read, so it can compute, validate, or look something up on the fly.
Think of it as
A property is a light switch, not a note taped to the wall — flipping it (reading obj.value) triggers real wiring behind the panel every time, even though it looks exactly like reading a fixed label. A plain attribute IS the note; a property is the switch that runs code and hands back whatever it decides to.
What we're doing: Expose a computed value (area) as a read-only property, and show that reading it re-runs the calculation every time the underlying data changes.
- 5
- @property turns area into an attribute-style lookup — defined like a method, read without parentheses.
- 6
- The body runs fresh every time c.area is read — this is a computed value, not stored state.
- 13
- radius changes, and the next c.area read reflects it immediately, because the method reruns rather than returning a cached number.
12.56636
50.26544Why this works: c.area looks exactly like reading a stored attribute, but it is really calling the area method every single time — that is what makes the second print show a different, correctly recomputed number after c.radius changed, with no cache to invalidate and no extra call needed anywhere in the calling code.
Calling a property like a method, with parentheses
Wrong
Better
What you see: TypeError: 'float' object is not callable — because c.area already evaluated to a float before the () was even applied to it.
Why: @property's entire point is making a method readable with attribute syntax — c.area already runs the method and returns its result (a float here). Writing c.area() then tries to call that float as if it were a function, which floats do not support.
- obj.area — no parentheses, looks like an attribute
- @property method runs — computes the value fresh, every read
- returns a plain value — caller never sees the method call
Plain attribute vs. @property, from the caller's side
Together
Remember: @property makes a method readable as obj.name, no parentheses — it reruns on every read and is read-only unless a setter is added.
See also: property setters · computed properties · instance methods

