I would like to find out disadvantages of using exec
for imports. One of the files serves as interface towards real implementations of specific functionalities depending on chosen project (framework is intended to work on several projects).
First use-case goes like this:
exec ("from API.%s.specific_API_%s import *" % (project, project))
This way I don't have to hard code anything except the variable project
which is injected in the interface-module itself.
This is the other way:
if project == 'project_one':
from API.project_one.specific_API_project_one import *
elif project == 'project_two':
from API.project_two.specific_API_project_two import *
elif project == 'project_three':
from API.project_three.specific_API_project_three import *
This way I have to alter this interface-file each time new project is added to be supported.