I have a file structure like this:
project_folder/
notebooks/
notebook01.ipynb
notebook02.ipynb
...
notebookXY.ipynb
module01.py
module02.py
module03.py
In .ipynb
files inside notebook/
folder I want to import classes and functions from module01.py, module02.py
and module03.py
.
I have found answer in this question that it is possible using following lines of code inside every notebook and run those lines as first cell every time:
import os
import sys
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path:
sys.path.append(module_path)
Is there please a better way for this? What if I have A LOT of .ipynb
files inside notebooks/
folder, do I have to paste those lines of code at the beginning of every single one? Is there a better, more minimalist or cleaner way?