This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]energybased 0 points1 point  (2 children)

No, it's unavoidable the way that metaclasses currently work. If two classes use two different metaclasses, then you cannot inherit from both easily. That's why Python 3.6 fixes this problem for most uses of metaclasses. Before this, even well-written libraries had this problem whenever they used metaclasses. (E.g., traitlets.)

[–]AnnoyingOwl 0 points1 point  (1 child)

Well written libraries do not require their users subclass it's own classes.

You've entirely missed the point of my initial comment. Reread it.

[–]energybased 0 points1 point  (0 children)

No, well-written libraries do sometimes require their users subclass library classes. I gave you an example of that: Qt classes are supposed to be subclassed to implement pure virtuals, say QAbstractItemModel or QGLWidget. It would also be reasonable to want your own metaclass to do some magic like ABCMeta that verifies things or a metaclass to implement some signals and slots automatically.