I am looking for a way to write an addon system for a Python 3 program that I am going to write. The program, after initializing everything else, would import the selected addons (Python scripts with code and/or functions) using a list that the user provided. The addons would then make the required changes to the program. A very simple implementation of the system would look like this:
for name in addons:
import name
Now, of course, this example does not work as the Python interpreter will try to import a module named 'name'. My question is, how do I use a variable to import a module? Or, if I can not do that, what would be the best way to implement an addon system?