epfml/ML_course

Importing files from different folder

junlulocky opened this issue · 0 comments

Since many students are asking for importing from different folders to reuse the code. Here is a useful link that can solve this problem.

https://stackoverflow.com/questions/4383571/importing-files-from-different-folder

Try the following:

sys.path.append('/path/to/application/app/folder')
import file

e.g.

sys.path.append('./scripts') # which means go to the scripts folder in the current folder
import helpers # import the helpers functions in the scripts folder