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
| Name | Description |
|---|---|
| fget | Optional function that gets the value. |
| fset | Optional function that sets the value. |
| fdel | Optional function that deletes the value. |
| doc | Optional 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)