property is created by assigning the result of built-in function to class attributeattribute property(fgetfsetfdeldocnone of this built-in' arguments are requiredand all default to none if not passed for the first threethis none means that the corresponding operation is not supportedand attempting it will raise an attributeerror exception automatically when these arguments are usedwe pass fget function for intercepting attribute fetchesfset function for assignmentsand fdel function for attribute deletions technicallyall three of these arguments accept any callableincluding class' methodhaving first argument to receive the instance being qualified when later invokedthe fget function returns the computed attribute valuefset and fdel return nothing (reallynone)and all three may raise exceptions to reject access requests the doc argument receives documentation string for the attributeif desiredotherwisethe property copies the docstring of the fget functionwhich as usual defaults to none this built-in property call returns property objectwhich we assign to the name of the attribute to be managed in the class scopewhere it will be inherited by every instance first example to demonstrate how this translates to working codethe following class uses property to trace access to an attribute named namethe actual stored data is named _name so it does not clash with the property (if you're working along with the book examples packagesome filenames in this are implied by the command-lines that run them following their listings)class personadd (objectin def __init__(selfname)self _name name def getname(self)print('fetch 'return self _name def setname(selfvalue)print('change 'self _name value def delname(self)print('remove 'del self _name name property(getnamesetnamedelname"name property docs"bob person('bob smith'print(bob namebob name 'robert smithprint(bob name managed attributes bob has managed attribute runs getname runs setname