accessor function and return the property object (self should sufficesince the prop erty built-in already does thiswe'll omit formal coding of this extension here descriptors and slots and more you can also probably now at least in part imagine how descriptors are used to implement python' slots extensioninstance attribute dictionaries are avoided by creating class-level descriptors that intercept slot name accessand map those names to sequential storage space in the instance unlike the explicit property callthoughmuch of the magic behind slots is orchestrated at class creation time both automatically and implicitlywhen __slots__ attribute is present in class see for more on slots (and why they're not recommended except in pathological use casesdescriptors are also used for other class toolsbut we'll omit further internals details heresee python' manuals and source code for more details in we'll also make use of descriptors to implement function decorators that apply to both functions and methods as you'll see therebecause descriptors receive both descriptor and subject class instances they work well in this rolethough nested functions are usually conceptually much simpler solution we'll also deploy descriptors as one way to intercept built-in operation method fetches in be sure to also see ' coverage of data descriptorsprecedence in the full inheritance model mentioned earlierwith __set__descriptors override other namesand are thus fairly binding--they cannot be hidden by names in instance dictionaries __getattr__ and __getattribute__ so farwe've studied properties and descriptors--tools for managing specific attributes the __getattr__ and __getattribute__ operator overloading methods provide still other ways to intercept attribute fetches for class instances like properties and descriptorsthey allow us to insert code to be run automatically when attributes are accessed as we'll seethoughthese two methods can also be used in more general ways because they intercept arbitrary namesthey apply in broader roles such as delegationbut may also incur extra calls in some contextsand are too dynamic to register in dir results attribute fetch interception comes in two flavorscoded with two different methods__getattr__ is run for undefined attributes--because it is run only for attributes not stored on an instance or inherited from one of its classesits use is straightforward __getattr__ and __getattribute__