I have written a JSON config file that lists all the inputs for running a package. That package, though, has several classes that are interchangeable. What is a pythonic way to define the imports from within the config file?
I essentially want a cleaner way of doing this:
if config.import_name == 'class_one':
from config.class_one_location import config.import_name as class
if config.import_name == 'class_two':
from config.class_two_location import config.import_name as class
As such, I can't do this because the import function doesn't accept variable names. I also don't believe I can use __import__ because I need to specify both the path and the module name within that path, although I may be misunderstanding.