这是我递归获取所有子类的类方法:
@classmethod
def get_subclasses(cls):
subclasses = set()
for subclass in cls.__subclasses__():
subclasses.add(subclass)
subclasses.update(subclass.get_subclasses())
return subclasses
有没有办法让它成为单线?就像是:
return set(subclass.__subclasses__() for subclass in self.__subclasses__())