Structuring Your Project
docs.python-guide.org
Structuring Your Project
1–10 of 40 posts
Re: Structuring Your Project
#2Re: Structuring Your Project
#3Should mention that __init__.py is not needed for python 3.3+ anymore (just found that out this week myself to my surprise) so for projects where backwards compatibility is not required you can stop creating extra blank files if you don't need them.
https://stackoverflow.com/questions/37139786/is-init-py-not-...
Re: Structuring Your Project
#4Guides like these are just full of (the wrong type of) rabbit holes. Just give new people something that lets them work productively as soon as possible and refer them to language documentation to understand how features of the language or the runtime work - in case they want to dig deeper.
Most people will not want to dig deeper, anyway. They will be happier to just have boilerplate that works and that they can iterate upon.
Look at the golang version of this guide: https://github.com/golang-standards/project-layout
How many programmers new to go are going to want to wade through all of that? Especially when they're probably starting out with projects for which most of those conventions don't even apply!
It's surprising to me that Python, as focused as its philosophy is on providing canonical solutions to problems, doesn't have a "python -m newproject". There must be a good reason. Will try making one in my free time to find out.
[0] https://github.com/facebook/create-react-app
[1] https://docs.djangoproject.com/en/2.2/ref/django-admin/#star...
[2] https://doc.rust-lang.org/cargo/guide/creating-a-new-project...
[3] https://github.com/technomancy/leiningen/blob/master/doc/TUT...
Re: Structuring Your Project
#5This month I'm working on a side project and learning to use sequelize (a SQL ORM for node). All the examples [1] just seem to assume my entire project live in a single file.
[1] https://sequelize.org/master/manual/models-definition.html
Re: Structuring Your Project
#6This is the kind of documentation I wish every language/framework provided. Every time I try to learn a new language/framework, I just see code fragments with no idea how to organize them coherently. This month I'm working on a side project and learning to use sequelize (a SQL ORM for node). All the examples [1] just seem to assume my entire project live in a single file. [1] https://sequelize.org/master/manual/model…
Re: Structuring Your Project
#7Modifying sys.path is an ugly hack which makes python look like some... idk. matlab?
Re: Structuring Your Project
#8When I'm just learning a new programming language or framework, I prefer to have something like create-react-app [0], django-admin startproject [1], cargo new [2], or lein new [3]. Guides like these are just full of (the wrong type of) rabbit holes. Just give new people something that lets them work productively as soon as possible and refer them to language documentation to understand how features of the language or…
[0]: https://poetry.eustace.io/
Re: Structuring Your Project
#9Nitpick: I'd rather use the python -m pytest way than modify sys.path (AKA "the django way"). Modifying sys.path is an ugly hack which makes python look like some... idk. matlab?
The guide presents a false dichotomy. The main package doesn't have to be in site-packages as the alternative to this sys.path hack. It just has to be accessible from your PYTHONPATH. Running tests as a module from the project root will put your main package on the PYTHONPATH.
Re: Structuring Your Project
#10When I'm just learning a new programming language or framework, I prefer to have something like create-react-app [0], django-admin startproject [1], cargo new [2], or lein new [3]. Guides like these are just full of (the wrong type of) rabbit holes. Just give new people something that lets them work productively as soon as possible and refer them to language documentation to understand how features of the language or…
`poetry new`[0] is what you are looking for, previously I have used pyscaffold[1] but I like the pyproject.toml from PEP 518[2] better than all the old stuff. Unfortunately poetry does not set up docs like pyscaffold does though. [0]: https://poetry.eustace.io/ [1]: https://pyscaffold.org/en/latest/ [2]: https://www.python.org/dev/peps/pep-0518/