In my project I have a generic class named Interface and many subclasses which inherit from Interface:
- /interface_folder/
- interface.py
- interface_a.py
- interface_b.py
- interface_c.py
- ...
- /test/
- test.py
The Interface class has a method which lists all the available methods of all its subclasses : their names, docstring, input and output arguments. I did this using the inspect module on Interface.__subclasses__()
.
In test.py, if I want the Interface method using __subclasses__()
to work, I need to import interface_a.py, interface_b.py, interface_c.py, etc.
I would like to automate these imports, so that I can add as many interface_x.py as I want in the folder without having to think of adding every time "from interface_folder.interface_d import Interface_d" at the beginning of test.py.
Is this possible?
If not, is there a solution to force python to build the __subclasses__()
?