when specific metaclass is declared per the prior sectionssyntaxthe call to create the class object run at the end of the class statement is modified to invoke the metaclass instead of the type defaultclass meta(classnamesuperclassesattributedictand because the metaclass is subclass of typethe type class' __call__ delegates the calls to create and initialize the new class object to the metaclassif it defines custom versions of these methodsmeta __new__(metaclassnamesuperclassesattributedictmeta __init__(classclassnamesuperclassesattributedictto demonstratehere' the prior section' example againaugmented with metaclass specificationclass spam(eggsmetaclass=meta)data def meth(selfarg)return self data arg inherits from eggsinstance of meta class data attribute class method attribute at the end of this class statementpython internally runs the following to create the class object--againa call you could make manually toobut automatically run by python' class machineryspam meta('spam'(eggs,){'data' 'meth'meth'__module__''__main__'}if the metaclass defines its own versions of __new__ or __init__they will be invoked in turn during this call by the inherited type class' __call__ methodto create and initialize the new class the net effect is to automatically run methods the metaclass providesas part of the class construction process the next section shows how we might go about coding this final piece of the metaclass puzzle this uses python metaclass keyword argument syntaxnot the class attribute readers will need to translatebut version neutrality is not straightforward here-- doesn' recognize the attribute and doesn' allow keyword syntax--and listing examples twice doesn' address portability (or size!coding metaclasses so farwe've seen how python routes class creation calls to metaclassif one is specified and provided howthoughdo we actually code metaclass that customizes typeit turns out that you already know most of the story--metaclasses are coded with normal python class statements and semantics by definitionthey are simply classes that inherit from type their only substantial distinctions are that python calls them metaclasses