Last modified: Nov 27, 2026

Python Property vs Attribute: Clear Guide

Many beginners use the words "property" and "attribute" as if they mean the same thing. They do not. The difference matters once you build real classes.

An attribute is a simple value stored on an object. A property is a method that behaves like an attribute. This guide explains both with clear examples.

What Is an Attribute?

An attribute is data attached to an object. You set it and read it directly. There is no logic in between.

Here is a plain class with two attributes:


class Person:
    def __init__(self, name, age):
        self.name = name   # plain attribute
        self.age = age     # plain attribute

p = Person("Ana", 30)
print(p.name)              # read the attribute
p.age = 31                 # change the attribute directly
print(p.age)

Ana
31

This is simple and fast. But nothing stops someone from writing p.age = -5. Bad data can slip in.

What Is a Property?

A property looks like an attribute from the outside. Inside, it runs a method. So you can add checks, calculations, or formatting.

You create one with the @property decorator. The method runs every time you read the value.

To learn the full mechanics, see what the property decorator does in Python.


class Circle:
    def __init__(self, radius):
        self._radius = radius   # "private" attribute

    @property
    def radius(self):
        return self._radius

    @property
    def area(self):
        return 3.14 * self._radius ** 2

c = Circle(5)
print(c.radius)   # looks like an attribute, runs a method
print(c.area)     # computed on the fly

5
78.5

Notice that c.area has no parentheses. It still runs code. That is the key idea.

Attribute vs Property: Side by Side

Storage: An attribute stores a value. A property computes or validates a value.

Access: An attribute is read directly. A property calls a method behind the scenes.

Control: An attribute has no control. A property can reject bad values or add logic.

Speed: An attribute is slightly faster. A property adds a small method call cost.

Refactoring: You can start with an attribute and later swap in a property without breaking user code.

This last point is a big reason properties exist. The public interface stays the same.

Adding a Setter for Validation

A read-only property is useful. But often you want to validate on write too. That is where a setter comes in.

The setter runs when you assign a value. You can raise an error for bad input.

For a full walkthrough, read the guide to Python class property setters.


class Person:
    def __init__(self, age):
        self.age = age          # triggers the setter

    @property
    def age(self):
        return self._age

    @age.setter
    def age(self, value):
        if value < 0:
            raise ValueError("Age cannot be negative")
        self._age = value

p = Person(30)
print(p.age)        # ok
p.age = -1          # blocked by the setter

30
ValueError: Age cannot be negative

The value is still stored in a normal attribute called _age. The property just guards the door.

When Should You Use a Property?

Use a property when reading or writing a value needs logic. Good cases include validation, computed values, and lazy loading.

Do not wrap every attribute in a property. Extra layers add noise. Keep it simple until you need control.

Here is a quick rule: plain data with no rules? Use an attribute. Data with rules or calculations? Use a property.

If you are unsure, this article on when to use property in Python breaks down the trade-offs.

Common Mistakes to Avoid

Mistake 1: Calling the property like a method. Write obj.area, not obj.area().

Mistake 2: Naming the storage attribute the same as the property. That causes infinite recursion.

Mistake 3: Forgetting the setter. A property without a setter is read-only, and assignment raises an error.

Mistake 4: Overusing properties for trivial data. This makes classes harder to read.

Watch the recursion trap closely. Inside the getter, always return the underscore version, like self._age.

Attributes on Lists and Built-in Objects

Properties are not only for your own classes. Built-in objects use them too. For example, list methods and behaviors are accessed through the object itself.

If you want to explore that topic, see this overview of Python list object properties.

The same idea applies to many standard types. They expose computed values through properties, not raw fields.

How Properties Fit Into Class Design

Properties support encapsulation. They hide internal details and expose a clean public API.

You can change the internals later. Callers still use obj.total. Nothing breaks.

This is a common pattern in libraries and frameworks. It keeps code stable as it grows.

Remember that properties are class-level descriptors. That means they live on the class, not on each instance. The instance only stores the underlying data.

Quick Comparison Table

Here is a short summary to keep in mind:


Feature        Attribute            Property
------------------------------------------------
Definition     Stored value         Method with @property
Access         Direct               Runs a getter
Write control  None                 Optional setter
Logic          Not possible         Validation, computing
Speed          Faster               Slightly slower
Use case       Simple data          Controlled data

Use this table as a checklist when you design a new class.

Conclusion

An attribute is raw data. A property is data with behavior attached. Both are useful, and both belong in good Python code.

Start with plain attributes. Add a property only when you need validation, computed values, or a stable API. Your classes will stay clean and readable.

The next time you write self.value = value, ask one question: does this value need rules? If yes, a property is your tool.