# metaclass Is the class used to create the class """ 1、 All things are objects ,python Of class( class ) It's also an object ( example ), It is tpye The object of ( example ) 2、 All classes inherit by default object 3、 The essence of creating classes is type Class instantiation class = tpye(), So for type Category self Is the class name. """ # Example 1、 Demonstrates the nature of creating classes class Foo1: def bar(self): print('hello Foo1') # The following expression is completely equivalent to the above """ 1、 All classes are tpye The object of , So creating a class is actually creating type The object of ,object Is the default parent of all classes ( Even if it is not declared when it is created ) 2、{'bar': fun} Show class Foo2 There's a function in bar, The corresponding function is fun """ def fun(self): print('hello Foo2') Foo2 = type('Foo2', (object,), {'bar': fun}) foo1 = Foo1() foo2 = Foo2() foo1.bar() foo2.bar()