In Python 2.7 is it possible to take user input and use this to determine which module gets loaded?
I tried something like:
userModule = raw_input("Which module to import? ")
from userModule import *
where there is no preexisting module called userModule…
Currently this returns: ImportError: No module named userModule
Use the
importlibmodule, and a littleglobals()trickery:Note how this is not the easiest and most straightforward task, and you may want to rethink the wisdom of doing this.