class MyClass(object): pass class SubClassA(MyClass): pass class SubClassB(MyClass): pass class SubClassC(MyClass): pass print([cls.__name__ for cls in vars()['MyClass'].__subclasses__()])
Output:
['SubClassA', 'SubClassB', 'SubClassC']
class MyClass(object): pass class SubClassA(MyClass): pass class SubClassB(MyClass): pass class SubClassC(MyClass): pass print([cls.__name__ for cls in vars()['MyClass'].__subclasses__()])
['SubClassA', 'SubClassB', 'SubClassC']
0 comments:
Post a Comment