automatically run methods through the decorator and rebind the original names to the results the effect is the same as the automatic method name rebinding of decoratorsbut we can apply it more globallymetaclass that adds tracing decorator to every method of client class from types import functiontype from decotools import tracer class metatrace(type)def __new__(metaclassnamesupersclassdict)for attrattrval in classdict items()if type(attrvalis functiontypeclassdict[attrtracer(attrvalreturn type __new__(metaclassnamesupersclassdictmethoddecorate it make class class person(metaclass=metatrace)def __init__(selfnamepay)self name name self pay pay def giveraise(selfpercent)self pay *( percentdef lastname(self)return self name split()[- bob person('bob smith' sue person('sue jones' print(bob namesue namesue giveraise print(' fsue payprint(bob lastname()sue lastname()when this code is runthe results are the same as before--calls to methods are routed to the tracing decorator first for tracingand then propagated on to the original methodc:\codepy - decoall-meta py call to __init__ call to __init__ bob smith sue jones call to giveraise call to lastname call to lastname smith jones the result you see here is combination of decorator and metaclass work--the metaclass automatically applies the function decorator to every method at class creation timeand the function decorator automatically intercepts method calls in order to print the trace messages in this output the combination "just works,thanks to the generality of both tools metaclasses