Suppose you have a base class A, and this class is reimplemented by B and C.
Suppose also there's a class method A.derived()
that tells you which classes are reimplementing A, hence returns [B, C], and if you later on have class D(A): pass
or class D(B): pass
, now A.derived()
returns [B,C,D].
How would you implement the method A.derived()
? I have the feeling that is not possible unless you use metaclasses. You can traverse the inheritance tree only from child to parent with the standard mechanism. To have the link in the other direction, you have to keep it "by hand", and this means overriding the traditional class declaration mechanics.