classes and object-oriented programming the abstract class mechanism addresses this issue by allowing preexisting objects to be organized into user-definable type hierarchies moreoversome library modules aim to organize the built-in types according to different capabilities that they possess the collections module contains abstract base classes for various kinds of operations involving sequencessetsand dictionaries the numbers module contains abstract base classes related to organizing hierarchy of numbers further details can be found in "mathematics,and "data structuresalgorithmsand utilities metaclasses when you define class in pythonthe class definition itself becomes an object here' an exampleclass foo(object)pass isinstance(foo,objectreturns true if you think about this long enoughyou will realize that something had to create the foo object this creation of the class object is controlled by special kind of object called metaclass simply stateda metaclass is an object that knows how to create and manage classes in the preceding examplethe metaclass that is controlling the creation of foo is class called type in factif you display the type of fooyou will find out that it is typetype(foowhen new class is defined with the class statementa number of things happen firstthe body of the class is executed as series of statements within its own private dictionary the execution of statements is exactly the same as in normal code with the addition of the name mangling that occurs on private members (names that start with _finallythe name of the classthe list of base classesand the dictionary are passed to the constructor of metaclass to create the corresponding class object here is an example of how it worksclass_name "fooname of class class_parents (object,base classes class_body ""class body def _init_ (self, )self def blah(self)print("hello world"""class_dict execute the body in the local dictionary class_dict exec(class_body,globals(),class_dictcreate the class object foo foo type(class_name,class_parents,class_dictthe final step of class creation where the metaclass type(is invoked can be customized the choice of what happens in the final step of class definition is controlled in lib fl ff