function objectsand class decorators can be used to manage both class instances and classes themselves by returning the decorated object itself instead of wrapperdecorators become simple post-creation step for functions and classes regardless of the role they playdecorators provide convenient and explicit way to code tools useful both during program development and in live production systems using and defining decorators depending on your job descriptionyou might encounter decorators as user or provider (you might also be maintainerbut that just means you straddle the fenceas we've seenpython itself comes with built-in decorators that have specialized roles --static and class method declarationproperty creationand more in additionmany popular python toolkits include decorators to perform tasks such as managing database or user-interface logic in such caseswe can get by without knowing how the decorators are coded for more general tasksprogrammers can code arbitrary decorators of their own for examplefunction decorators may be used to augment functions with code that adds call tracing or loggingperforms argument validity testing during debuggingautomatically acquires and releases thread lockstimes calls made to functions for optimizationand so on any behavior you can imagine adding to--reallywrapping around-- function call is candidate for custom function decorators on the other handfunction decorators are designed to augment only specific function or method callnot an entire object interface class decorators fill the latter role better --because they can intercept instance creation callsthey can be used to implement arbitrary object interface augmentation or management tasks for examplecustom class decorators can tracevalidateor otherwise augment every attribute reference made for an object they can also be used to implement proxy objectssingleton classesand other common coding patterns in factwe'll find that many class decorators bear strong resemblance to--and in fact are prime application of--the delegation coding pattern we met in why decoratorslike many advanced python toolsdecorators are never strictly required from purely technical perspectivewe can often implement their functionality instead using simple helper function calls or other techniques and at base levelwe can always manually code the name rebinding that decorators perform automatically that saiddecorators provide an explicit syntax for such taskswhich makes intent clearercan minimize augmentation code redundancyand may help ensure correct api usagewhat' decorator