Jason H. answered 03/30/19
Experienced professional working at big tech company
In Python, there are generally two ways of referencing files. One is by absolute path, and second, by relative path. From the sound of your question, looks like you are interested in knowing using relative path to path B (application/apps/some_folder/some_file.py) from path A (application/app/folder/file.py).
There are several methods for referencing files from your file.py, however I am only going to discuss about the method of interest here which is reference by module name. To do so, two things must be implemented:
- in each subfolder under application, app, and folder, __init__.py (can be an empty file) has to be created for python to recognized the existence of any modules.
- the current working directory must be pointed at the parent of the first referenced module. Taking the OP as an example, ./ should be the root in order to access "application" folder. There are two ways to make sure the current working directory (cwd) is pointing at the root: 1. cd to root and launch file.py via python ./application/app/folder/file.py or 2. launch file.py in any folder but use python's os module os.chdir to change to the root directory.
The above should get you going, hope this helps!