I am developing a Python project and the current structure of the project looks like this:
myproject
__init.__py
contents
- __init__.py
- content1.py
...
configs
- __init__.py
- config.py
...
utils
- __init__.py
- helpers.py
..
app.py
Now If I want to access functions from config.py
in the configs
directory to helpers.py
, I need to add these two lines in helpers.py
at the top:
import sys
sys.path.append("..")
Similary I have to add these lines in py files in each directory if I want to access them. This clearly doesn't feel the right way. Is there any other way to make the absolute
and relative
imports cleaner and easier? Any explanation on top of it would be very very helpful