Skip to content
Built-in Functions

property()

Create a managed attribute for a class.

property(fget=None, fset=None, fdel=None, doc=None)

A property lets code use an attribute-style name while a method does work behind the scenes.

The @property decorator is the common, readable way to make one.

Parameters

NameDescription
fgetOptional function that gets the value.
fsetOptional function that sets the value.
fdelOptional function that deletes the value.
docOptional description for the property.

Returns

A property object.

Try it

Run it and change it
class Person:
    def __init__(self, name): self._name = name
    @property
    def name(self): return self._name.title()
print(Person("ada").name)

Related entries