Import Numerous Modules
Question: I'm working on my making a simple tester for my project, my project is a group
of many self contained python files (e.g. solution1.py, solution2.py, etc.).
My tester works, but it requires me to do `import solution1, solution2, ...`,
how can I just import everything that matches a pattern?

I have tried creating a list of the files using glob and importing the list,
but that gave:

    
    
    ImportError: No module named solutions
    

I tried to eval() it, but that was 'invalid syntax'.

Perhaps the question is, how can I interpolate a list of strings into a list
of modules?

Thanks!


Answer: You can import a module identified by a string with the
[`importlib`](https://docs.python.org/2/library/importlib.html) module:

    
    
    import importlib
    
    list_of_module_names = ...
    for s in list_of_module_names:
        importlib.import_module(s)
    

