numinstancesy numinstancesz numinstances ( spam numinstancessub numinstancesother numinstances ( per-class datastatic and class methods have additional advanced roleswhich we will finesse heresee other resources for more use cases in recent python versionsthoughthe static and class method designations have become even simpler with the advent of function decoration syntax-- way to apply one function to another that has roles well beyond the static method use case that was its initial motivation this syntax also allows us to augment classes in python and --to initialize data like the numinstances counter in the last examplefor instance the next section explains how for postscript on python' method typesbe sure to watch for coverage of metaclass methods in --because these are designed to process class that is an instance of metaclassthey turn out to be very similar to the class methods defined herebut require no classmethod declarationand apply only to the shadowy metaclass realm decorators and metaclassespart because the staticmethod and classmethod call technique described in the prior section initially seemed obscure to some observersa device was eventually added to make the operation simpler python decorators--similar to the notion and syntax of annotations in java--both addressed this specific need and provided general tool for adding logic that manages both functions and classesor later calls to them this is called "decoration,but in more concrete terms is really just way to run extra processing steps at function and class definition time with explicit syntax it comes in two flavorsfunction decorators--the initial entry in this setadded in python --augment function definitions they specify special operation modes for both simple functions and classesmethods by wrapping them in an extra layer of logic implemented as another functionusually called metafunction class decorators-- later extensionadded in python and --augment class definitions they do the same for classesadding support for management of whole objects and their interfaces though perhaps simplerthey often overlap in roles with metaclasses function decorators turn out to be very general toolsthey are useful for adding many types of logic to functions besides the static and class method use cases for instancethey may be used to augment functions with code that logs calls made to themchecks the types of passed arguments during debuggingand so on function decorators can be used to manage either functions themselves or later calls to them in the latter mode advanced class topics