I would like to import modules from subdirectories in an easy way:
I would like to call all the functions in the app.py
.
├── app.py
└── testsubdir
└── testsubsubdir
├── utils.py
testsubdir2
└── testsubsubdir2
├── utils2.py
To do this I use now:
sys.path.append('/home/www/testsubdir/testsubsubdir')
sys.path.append('/home/www/testsubdir2/testsubsubdir2')
from utils import <some_function>
from utils2 import <some_function>
- Is there a way to get /home/www as main path of the python calling script, so I don't need to write it every time. Something like this? sys.path.append('$MAINPATH.'/testsubdir2/testsubsubdir2')
- Is there a way to tell put all the subdirectories from the root of the project /home/www to the sys.path, so they are used to include libs?