Code Explanation
class Meta(type):
pass
Defines a custom metaclass Meta
Meta inherits from type, which means it is a metaclass.
A metaclass is a class that defines how other classes are created.
class A(metaclass=Meta):
pass
Defines a class A using Meta as its metaclass.
Normally, Python uses type as the default metaclass.
Here, Meta replaces type, meaning Meta controls the creation of A.
print(type(A))
Prints the type of A
Since A was created using Meta, type(A) will return Meta.
Final Output:
<class '__main__.Meta'>
0 Comments:
Post a Comment