class Test: pass
print(Test.__subclasses__())
returns:
AttributeError: class Test has no attribute '__subclasses__'
And
print(int.__subclasses__())
returns:
[<type 'bool'>]
Why can’t I call subclasses() on my custom object?
This build in methods aren’t reserver for custom types, are they?
Each class keeps a list of weak references to its immediate subclasses. This method returns a list of all those references still alive. Example:
You will need to do this:-
The class above is a “new-style” class because it inherits from the object class. New-style classes provide a lot of extra framework that “old-style” classes do not have. One particular attribute of a new-style class is to be able to determine the subclasses of the class with the subclasses method.