I'm currently working on a modular python framework. The current dilemma is, that one module has a set of submodules that have vastly different dependencies, and a user usually would only use one of those based on his choice. As I want to include examples for all, I also import those modules in some example files outside of the project structure.
The question I'm having is the following: Python will throw exceptions as for submodule_Y as some libraries are missing (and we do not want to install them). Is there a best way to avoid this issue?
my current approach in the __init__.py of the parent module is the following:
try:
import submodule_Y
except:
pass
This is not good practice, so I was wondering what would be the optimal way to ignore exceptions if a certain submodule is not wanted by the user.