the __setattr__ method in this code relies on an instance object' __dict__ attribute namespace dictionary in order to set oninstance' own wrapped attribute as we learned in the prior this method cannot assign an attribute directly without looping howeverit uses the setattr built-in instead of __dict__ to set attributes in the wrapped object itself moreovergetattr is used to fetch attributes in the wrapped objectsince they may be stored in the object itself or inherited by it because of thatthis code will work for most classes--including those with "virtualclass-level attributes based on slotspropertiesdescriptorsand even __getattr__ and its ilk by assuming namespace dictionary for itself only and using storage-neutral tools for the wrapped objectthe wrapper class avoids limitations inherent in other tools for exampleyou may recall from that new-style classes with __slots__ may not store attributes in __dict__ (and in fact may not even have one of these at allhoweverbecause we rely on __dict__ only at the oninstance level hereand not in the wrapped instancethis concern does not apply in additionbecause setattr and getattr apply to attributes based on both __dict__ and __slots__our decorator applies to classes using either storage scheme by the same reasoningthe decorator also applies to new-style properties and similar toolsdelegated names will be looked up anew in the wrapped instanceirrespective of attributes of the decorator proxy object itself generalizing for public declarationstoo now that we have private implementationit' straightforward to generalize the code to allow for public declarations too--they are essentially the inverse of private declarationsso we need only negate the inner test the example listed in this section allows class to use decorators to define set of either private or public instance attributes --attributes of any kind stored on an instance or inherited from its classes--with the following semanticsprivate declares attributes of class' instances that cannot be fetched or assignedexcept from within the code of the class' methods that isany name declared private cannot be accessed from outside the classwhile any name not declared private can be freely fetched or assigned from outside the class public declares attributes of class' instances that can be fetched or assigned from both outside the class and within the class' methods that isany name declared public can be freely accessed anywherewhile any name not declared public cannot be accessed from outside the class private and public declarations are intended to be mutually exclusivewhen using privateall undeclared names are considered publicand when using publicall undeclared names are considered private they are essentially inversesthough undeclared names not created by class' methods behave slightly differently--new names decorators