I'm 'reposting' this question with more detail because I feel it was misunderstood the first time. I have a folder structure that looks like so:
folder w space
├── folder1
│ └── subfolder1
│ └── file_1.py
└── folder2
└── folder w space2
└── file_2.py
└── __init__.py
I'm needing to have file_1.py
import the methods from file_2.py
. Notice that file_2.py
, in relation to file_1.py
, is 3 directories up and then 3 directories down. I would, in theory, write the relative import as so:
from ...folder2 import folder w space2.file2
However this is not valid due to the spacing in the subfolder. An absolute import is even worse because the base folder contains spaces too:
from folder w space.folder2.folder w space2.file2
With this, how can I access the contents of file_2.py
without:
- Renaming the folders (I don't own them so I can't even if I wanted to)
- Without using
sys.path.append()
(does not work well in our production env) - Moving
file_2.py
(for organization must stay where it is)
Any help would be immensely appreciated!