run by the metaclass' __init__c:\codepy - metaclass py making class in metatwo newspam (,{'data' 'meth''__module__''__main__'in metatwo initspam (,{'data' 'meth''__module__''__main__'init class object['__qualname__''data''__module__''meth''__doc__'making instance data other metaclass coding techniques although redefining the type superclass' __new__ and __init__ methods is the most common way to insert logic into the class object creation process with the metaclass hookother schemes are possible using simple factory functions for examplemetaclasses need not really be classes at all as we've learnedthe class statement issues simple call to create class at the conclusion of its processing because of thisany callable object can in principle be used as metaclassprovided it accepts the arguments passed and returns an object compatible with the intended class in facta simple object factory function may serve just as well as type subclassa simple function can serve as metaclass too def metafunc(classnamesupersclassdict)print('in metafunc'classnamesupersclassdictsep='\ 'return type(classnamesupersclassdictclass eggspass print('making class'class spam(eggsmetaclass=metafunc)data def meth(selfarg)return self data arg run simple function at end function returns class print('making instance' spam(print('data:' datax meth( )coding metaclasses