Generic metaclass to keep track of subclasses?

前端 未结 3 1227
生来不讨喜
生来不讨喜 2021-02-20 05:26

I\'m trying to write a generic metaclass to track subclasses

Since I want this to be generic, I didn\'t want to hardcode any class name within this metaclass, therefore

3条回答
  •  误落风尘
    2021-02-20 06:06

    Python does this automatically for new-style classes, as mentioned in this answer to the similar queston How to find all the subclasses of a class given its name? here.

提交回复
热议问题