liveBook · Manning

Property decorator

In Python, the property decorator creates an attribute-like interface to methods that can retrieve, set, or delete an object's managed value.

How 2 Manning books explain it

The Well-Grounded Python Developer: How the pros use Python and Flask

A Python property decorator defines attribute-like access backed by methods that can compute, validate, or otherwise control attribute values.

How it is used
Keeps rectangle coordinate updates readable while controlling access and movement at screen boundaries.
How deep it goes
Works through a getter and boundary-aware setter, contrasting them with explicit methods; does not develop an exhaustive property reference.
Examples
Uses a moving rectangle, contrasting direct coordinate updates with explicit getter and setter calls.
What you can do after
Apply it via Python’s `@property` and `@x.setter` decorators to control coordinate updates without changing callers’ attribute syntax.

Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains property decorator →

Software Design for Python Programmers

The Python property decorator converts a method into a managed attribute interface backed by getter, setter, or deleter methods.

How it is used
Uses properties to hide class implementations while providing controlled, attribute-like access to object state.
How deep it goes
Explains getter creation, read-only behavior, calculated values, setter validation, and implementation substitution without covering deleters.
Examples
Demonstrates Book attributes, Circle calculations, and Item.price validation through concrete Python listings.
What you can do after
Build it from scratch by exposing attributes through getters and adding validating setters without leaking storage details.

Read how Software Design for Python Programmers explains property decorator →

Related concepts

Questions about property decorator

What is property decorator?

In Python, the property decorator creates an attribute-like interface to methods that can retrieve, set, or delete an object's managed value.

Which Manning books explain property decorator?

The Well-Grounded Python Developer: How the pros use Python and Flask and Software Design for Python Programmers.

What is property decorator a kind of?

Property decorator is a kind of decorator. A decorator is a programming-language construct that adds metadata or behavior to, or transforms, a program declaration, often a function or class.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.