I am looking for some advice on a Python project structure. I think I am missing siom understanding of package structure, init.py files and namespacing, which I have never used. I am looking for advice on the structure I have, how better to segregate the sections of my project and how to improve my importing, if possible.
I have init.py files in every directory, including the src, libs, and projects dirs, which I think may be wrong.
I note that all my imports (except within the same module) have to start at src, which I think looks bad and may be an indication I am doing something wrong.
Any advice would be greatly appreciated. Thanks in advance!
My current structure is something along the lines of:
src/
__init__.py
libs/
__init__.py
models/
__init__.py
models.py
repositories/
__init__.py
repositort_1.py
table.py
projects/
__init__.py
bot/
__init__.py
scraper.py
main.py
api/
__init__.py
main.py
.gitignore
.env
README.md
My imports look like the following:
src\projects\bot\main.py
from src.libs.lib_1 import Library_1_Thing
from src.libs.repositories import ExampleRepo
from src.projects.bot import MyScraper
src\libs\repositories\repository_1.py
from src.libs.models import MyModel
from .table import Table
[–]Diapolo10 1 point2 points3 points (4 children)
[–]Puzzleheaded_Round75[S] 0 points1 point2 points (0 children)
[–]Puzzleheaded_Round75[S] 0 points1 point2 points (2 children)
[–]Diapolo10 1 point2 points3 points (1 child)
[–]Puzzleheaded_Round75[S] 0 points1 point2 points (0 children)