to define function that will run automatically when an attribute is fetchedclass person@property def name(self)rebindsname property(namewhen runthe decorated method is automatically passed to the first argument of the property built-in this is really just alternative syntax for creating property and rebinding the attribute name manuallybut may be seen as more explicit in this roleclass persondef name(self)name property(namesetter and deleter decorators as of python and property objects also have gettersetterand deleter methods that assign the corresponding property accessor methods and return copy of the property itself we can use these to specify components of properties by decorating normal methods toothough the getter component is usually filled in automatically by the act of creating the property itselfclass persondef __init__(selfname)self _name name @property def name(self)"name property docsprint('fetch 'return self _name @name setter def name(selfvalue)print('change 'self _name value @name deleter def name(self)print('remove 'del self _name bob person('bob smith'print(bob namebob name 'robert smithprint(bob namedel bob name print('-'* sue person('sue jones'print(sue nameprint(person name __doc__name property(namename name setter(namename name deleter(namebob has managed attribute runs name getter (name runs name setter (name runs name deleter (name sue inherits property too or help(person nameproperties