Users must understand the differences and interactions between metaclass programming and traditional object-oriented programming (under both single and multiple inheritance).
用户必须理解元类编程和传统面向对象编程的不同点和相同点(单继承和多继承)。
As well as being a class, Duke is an instance of the metaclass Nobility — attribute lookup proceeds as with any object.
Duke是一个类,也是元类Nobility的一个实例——属性的查找过程与其他对象一致。
You can still enforce a attribute value using a metaclass, you just need to set it on the class object being instantiated rather than as an attribute of the metaclass.
您仍然可以使用元类来增强属性,只需在被实例化的类对象上进行设置,而不是像元类的属性那样。
应用推荐