Skip to main content
2 of 7
added 178 characters in body
Nihathrael
  • 641
  • 4
  • 12

Using exec() is generally regarded as bad practice (http://stackoverflow.com/questions/1933451/why-should-exec-and-eval-be-avoided). Since you are trying to import a module, you can do the same by using the importlib package.

Python 2: https://docs.python.org/2/library/importlib.html

Python 3: https://docs.python.org/3/library/importlib.html#module-importlib

Using it should clean up the rest of the code as well.

You might also be interested in this discussion for more possibilities regarding imports: http://stackoverflow.com/questions/1057431/loading-all-modules-in-a-folder-in-python

Nihathrael
  • 641
  • 4
  • 12