File: LP6E/Chapter31/trace.py

class Wrapper:
    def __init__(self, object):
        self.wrapped = object                    # Save object
    def __getattr__(self, attrname):
        print('Trace: ' + attrname)              # Trace fetch
        return getattr(self.wrapped, attrname)   # Delegate fetch



[Home page] Books Code Blog Python Author Train Find ©M.Lutz