Hi, I was wondering how to get around a problem I was having with eval(). I have a list of strings and each one is the name of a python file found in the same directory as the current script. I was it to import these modules to use in the current script, but: eval( "import" + modname ), where 'modname' is the script's name, causes an error. Is there any way to have the script import any found scripts or would I have to explicitly add "import <name>" for each script? Thanks!
names = [ "main", "secondary", "tertiary" ] for item in names: eval( "import " + item )
The code above makes sense, but python gives me this instead:
import primary ^ SyntaxError: invalid syntax