I have a list of module names in an array. I would like to import all these modules from an already imported class. It seems like I can't use from TestModule __import__(name)
How can I do that? Here is what I have:
import MainModule
arr = \
['Module1', 'Module2', 'Module3', 'Module4', 'Module5']
for string in arr:
# Use FROM to import the sub classes somehow
from MainModule __import__(string)
Of course Python won't allow me to do that.