I have a file with all the modules that I use for my project:
# setup.py
import A
import B
import C
I then call these modules from a different file as:
from setup import *
Suppose I now have a list of keys for these modules:
my_modules = ['A', 'B', 'C']
I wanto import them in my setup.py file dynamically. So I used:
import importlib
for key in my_modules:
importlib.import_module(key)
My problem is that this doesn't let me use the names in my main script:
from setup import * # imports A, B and C but no global name is assigned.
A.some_function()
...returns that the module is not defined. How can I make the "true" name of the modules be available globally?