RetroFed Forum
Your home away from modern life.
How to import local files which import local files themselves?
Post Reply
AuthorMessage
Limitless_screaming kbin.earth Limitless_screaming@kbin.earth
Joined: 2024-12-17
Quote

With a project structure like this:

├─main.py
└─src
    ├─dep1.py
    └─dep2.py

where the contents of each file is as follows:

main.py: import src.dep1 as firstdep; print("Total success")

dep1.py: import dep2 as seconddeb; print("success 1/3")

dep2.py: print("success 2/3")

Is the best way to do this creating an __init__.py file in src and importing src.dep2 in dep1.py? or is this a bad idea?

1   Original
Post Reply
Back to top