through changes or proxiesinstead of more direct relationship as we'll see heremetaclassesby contrastrun during class creation to make and return the new client class thereforethey are often used for managing or augmenting classes themselvesand can even provide methods to process the classes that are created from themvia direct instance relationship for examplemetaclasses can be used to add decoration to all methods of classes automaticallyregister all classes in use to an apiadd user-interface logic to classes automaticallycreate or extend classes from simplified specifications in text filesand so on because they can control how classes are made--and by proxy the behavior their instances acquire--metaclass applicability is potentially very wide as we'll also see herethoughthese two tools are more similar than different in many common roles since tool choices are sometimes partly subjectiveknowledge of the alternatives can help you pick the right tool for given task to understand the options betterlet' see how metaclasses stack up the downside of "helperfunctions also like the decorators of the prior metaclasses are often optional from theoretical perspective we can usually achieve the same effect by passing class objects through manager functions--sometimes known as helper functions--much as we can achieve the goals of decorators by passing functions and instances through manager code just like decoratorsthoughmetaclassesprovide more formal and explicit structure help ensure that application programmers won' forget to augment their classes according to an api' requirements avoid code redundancy and its associated maintenance costs by factoring class customization logic into single locationthe metaclass to illustratesuppose we want to automatically insert method into set of classes of coursewe could do this with simple inheritanceif the subject method is known when we code the classes in that casewe can simply code the method in superclass and have all the classes in question inherit from itclass extrasdef extra(selfargs)normal inheritancetoo static class client (extras)class client (extras)class client (extras)clients inherit extra methods client ( extra(make an instance run the extra methods to metaclass or not to metaclass