已读95%
预计阅读本页时间:-
预计阅读本页时间:-
Coding Metaclasses
So far, we’ve seen how Python routes class creation calls to a metaclass, if one is provided. How, though, do we actually code a metaclass that customizes type?
It turns out that you already know most of the story—metaclasses are coded with normal Python class statements and semantics. Their only substantial distinctions are that Python calls them automatically at the end of a class statement, and that they must adhere to the interface expected by the type superclass.