object interface python provides few built-in function decorators for operations such as marking static and class methods and defining properties (as sketched earlierthe property built-in works as decorator automatically)but programmers can also code arbitrary decorators of their own although they are not strictly tied to classesuser-defined function decorators often are coded as classes to save the original functions for later dispatchalong with other data as state information this proved such useful hook that it was extended in python and --class decorators bring augmentation to classes tooand are more directly tied to the class model like their function cohortsclass decorators may manage classes themselves or later instance creation callsand often employ delegation in the latter mode as we'll findtheir roles also often overlap with metaclasseswhen they dothe newer class decorators may offer more lightweight way to achieve the same goals function decorator basics syntacticallya function decorator is sort of runtime declaration about the function that follows function decorator is coded on line by itself just before the def statement that defines function or method it consists of the symbolfollowed by what we call metafunction-- function (or other callable objectthat manages another function static methods since python for examplemay be coded with decorator syntax like thisclass @staticmethod def meth()function decoration syntax internallythis syntax has the same effect as the following--passing the function through the decorator and assigning the result back to the original nameclass cdef meth()meth staticmethod(methname rebinding equivalent decoration rebinds the method name to the decorator' result the net effect is that calling the method function' name later actually triggers the result of its staticme thod decorator first because decorator can return any sort of objectthis allows the decorator to insert layer of logic to be run on every call the decorator function is free to return either the original function itselfor new proxy object that saves the original function passed to the decorator to be invoked indirectly after the extra logic layer runs with this additionhere' better way to code our static method example from the prior section in either python or xdecorators and metaclassespart