importlib python module can be used for importing python module/package at runtime dynamically
Please visit importlib for details
Modules going to be imported at runtime should be placed under /magic_files folder. Currently there are two files under this folder.
file1.py
file2.py
To run application with selected module executed at runtime:
python main.py file1
You should see /files/file1.py included and run dynamically
running magic file 1
file1
0:00:00.001981
If specified file cannot be found under ./dynamic_files folder you will get an error:
no magic file with name [random_file] found under ./dynamic_files folder