I have a python app with a file tree like so
├── app
│ ├── __init__.py
│ ├── app.py
│ └── utils.py
├── files.json
├── hello.txt
├── main.py
└── web
├── __init__.py
├── utils.py
└── web.py
In my main.py, I have to import the contents of web.py with the import statement
from web.web import *. How can I shorten this to from web import * while still keeping web.py and utils.py in their own folder? Is there something I can edit in my __init__.py?
>Solution :
you can import things in web/__init__.py and your main.py will import these things when from web import *.
try this:
# main.py
from web import *
print(TEST)
# web/__init__.py
from .web import *
# web/web.py
TEST = "test"
and you will see test in the console when you run python main.py