(see and for more on the __dict__ attributeyou can use the approach of this module' wrapper class to manage access to any object with attributes--listsdictionariesand even classes and instances herethe wrapper class simply prints trace message on each attribute access and delegates the attribute request to the embedded wrapped objectfrom trace import wrapper wrapper([ ] append( traceappend wrapped [ wrapper({' ' ' ' }list( keys()tracekeys [' '' 'wrap list delegate to list method print my member wrap dictionary delegate to dictionary method the net effect is to augment the entire interface of the wrapped objectwith additional code in the wrapper class we can use this to log our method callsroute method calls to extra or custom logicadapt class to new interfaceand so on we'll revive the notions of wrapped objects and delegated operations as one way to extend built-in types in the next if you are interested in the delegation design patternalso watch for the discussions in and of function decoratorsa strongly related concept designed to augment specific function or method call rather than the entire interface of an objectand class decoratorswhich serve as way to automatically add such delegation-based wrappers to all instances of class version skew noteas we saw by example in delegation of object interfaces by general proxies has changed substantially in when wrapped objects implement operator overloading methods technicallythis is new-style class differenceand can appear in code too if it enables this optionper the next it' mandatory in and thus often considered change in python ' default classesoperator overloading methods run by built-in operations are routed through generic attribute interception methods like __getattr__ printing wrapped object directlyfor examplecalls this method for __repr__ or __str__which then passes the call on to the wrapped object this pattern holds for __iter____add__and the other operator methods of the prior in python xthis no longer happensprinting does not trigger __get attr__ (or its __getattribute__ cousin we'll study in the next and default display is used instead in xnew-style classes look up methods invoked implicitly by built-in operations in classes and skip the normal instance lookup entirely explicit name attribute fetches are routed to __getattr__ the same way in both and xbut built-in oop and delegation"wrapperproxy objects