This is likely dependent on what you are building. The article I linked in my comment breaks out different layouts like so:
CLI Layouts:
- One-Off Script
- Installable Single Package
- Application with Internal Packages
Web App Layouts:
- Django
- Flask
While link only answers are discouraged here, I think its counter productive to rehash the whole article but the "Installable Single Package" layout has worked for me and looks like this (borrowed from the same article):
helloworld/
β
βββ helloworld/
β βββ __init__.py
β βββ helloworld.py
β βββ helpers.py
β
βββ tests/
β βββ helloworld_tests.py
β βββ helpers_tests.py
β
βββ .gitignore
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ setup.py
NOTE: If you have a data directory, I would put it at the same level as tests
Python git project-structure convention? - Stack Overflow
Where can I learn how to structure a Python project?
I use this sample project on GitHub as a template for my Python projects. The project itself is still actively maintained.
More on reddit.comWhatβs your approach to organizing Python projects for readability and scalability?
Project structure best practices
As of now every project on my github is just 1 or 2 Python files. Iβve looked at many different projects on github and the majority of them have many different folders and files and I have no clue what their purpose is. Where can I read about properly structuring a Python project?
I use this sample project on GitHub as a template for my Python projects. The project itself is still actively maintained.
I highly recommend Hypermodern Python. I just went through it and it has taught me a lot. It guides you through everything from setting up a Github repo, making a project using Poetry, unit tests, linting, all the way to CI and release. It's great.