although manager functions like this one can achieve our goal herethey still put fairly heavy burden on class coderswho must understand the requirements and adhere to them in their code it would be better if there was simple way to enforce the augmentation in the subject classesso that they don' need to deal with the augmentation so explicitlyand would be less likely to forget to use it altogether in other wordswe' like to be able to insert some code to run automatically at the end of class statementto augment the class this is exactly what metaclasses do--by declaring metaclasswe tell python to route the creation of the class object to another class we providedef extra(selfarg)class extras(type)def __init__(classclassnamesuperclassesattributedict)if required()class extra extra class client (metaclass=extras)class client (metaclass=extras)class client (metaclass=extras)metaclass declaration only ( formclient class is instance of meta client ( extra( is instance of client because python invokes the metaclass automatically at the end of the class statement when the new class is createdit can augmentregisteror otherwise manage the class as needed moreoverthe only requirement for the client classes is that they declare the metaclassevery class that does so will automatically acquire whatever augmentation the metaclass providesboth now and in the future if the metaclass changes of coursethis is the standard rationalewhich you'll need to judge for yourself--in truthclients might forget to list metaclass just as easily as they could forget to call manager functionstillthe explicit nature of metaclasses may make this less likely moreovermetaclasses have additional potentials we haven' yet seen although it may be difficult to glean from this small examplemetaclasses generally handle such tasks better than more manual approaches metaclasses versus class decoratorsround having said thatit' also important to note that the class decorators described in the preceding sometimes overlap with metaclasses--in terms of both utility and benefit although they are often used for managing instancesclass decorators can also augment classesindependent of any created instances their syntax makes their usage similarly explicitand arguably more obvious than manager function calls for examplesuppose we coded our manager function to return the augmented classinstead of simply modifying it in place this would allow greater degree of flexibilityto metaclass or not to metaclass