Lesson 9: @property — controlled reading
acc.get_balance() works, but feels clunky. Python offers an elegant fix: @property — a method that reads like an attribute, no parentheses. You get clean syntax and full control over reading.
@property is an automatic door: from outside it looks like you just walk in (acc.balance), but behind the scenes code runs to open the door every time.
- property
- A method marked with @property and read without parentheses — like a plain attribute, but with code behind it.
- decorator
- A line starting with @ above a method definition that changes how it behaves.