kinds of classes in full detailthis all works out quite naturally--in xand in new-style classestype is class that generates user-defined classes metaclasses are subclasses of the type class class objects are instances of the type classor subclass thereof instance objects are generated from class in other wordsto control the way classes are created and augment their behaviorall we need to do is specify that user-defined class be created from user-defined metaclass instead of the normal type class notice that this type instance relationship is not quite the same as normal inheritance user-defined classes may also have superclasses from which they and their instances inherit attributes as usual as we've seeninheritance superclasses are listed in parentheses in the class statement and show up in class' __bases__ tuple the type from which class is createdthoughand of which it is an instanceis different relationship inheritance searches instance and class namespace dictionariesbut classes may also acquire behavior from their type that is not exposed to the normal inheritance search to lay the groundwork for understanding this distinctionthe next section describes the procedure python follows to implement this instance-of type relationship class statement protocol subclassing the type class to customize it is really only half of the magic behind metaclasses we still need to somehow route class' creation to the metaclassinstead of the default type to fully understand how this is arrangedwe also need to know how class statements do their business we've already learned that when python reaches class statementit runs its nested block of code to create its attributes--all the names assigned at the top level of the nested code block generate attributes in the resulting class object these names are usually method functions created by nested defsbut they can also be arbitrary attributes assigned to create class data shared by all instances technically speakingpython follows standard protocol to make this happenat the end of class statementand after running all its nested code in namespace dictionary corresponding to the class' local scopepython calls the type object to create the class object like thisclass type(classnamesuperclassesattributedictthe type object in turn defines __call__ operator overloading method that runs two other methods when the type object is calledthe metaclass model