python-guide icon indicating copy to clipboard operation
python-guide copied to clipboard

please add flask in "Structuring Your Project"

Open Yensan opened this issue 6 years ago • 6 comments

Writing Great Python Code ---- Structuring Your Project ----------Regarding Django Applications

Structure of Code is Key, it is true. In this paragraph, someone writes about Django, but I must say Flask is a big problem, because when you use django shell to create a project, it will always as it designed, if you use Flask... project structure will be different with everyone. For this reason, I think flask is not safe for human consumption at all. 😆 If anyone can create an example project ?

Yensan avatar Apr 14 '19 16:04 Yensan

What about cookiecutter templates? https://github.com/sloria/cookiecutter-flask https://github.com/candidtim/cookiecutter-flask-minimal https://github.com/karec/cookiecutter-flask-restful

In my opinion there is no perfect project structure. It also applies to Django and any other python web framework.

kedod avatar Apr 28 '19 09:04 kedod

@Yensan I agree w/ you that structuring Flask projects is more open-ended than Django.

Rather than pulling Flask into the guide, however, I think the section entitled 'Regarding Django Applications' should be edited to 'Avoid Repetitive Paths'.

I've written a blog post about this problem, a lot of Python projects in addition to Django make this mistake.

zachvalenta avatar Jun 18 '19 18:06 zachvalenta

@Yensan I agree w/ you that structuring Flask projects is more open-ended than Django.

Rather than pulling Flask into the guide, however, I think the section entitled 'Regarding Django Applications' should be edited to 'Avoid Repetitive Paths'.

I've written a blog post about this problem, a lot of Python projects in addition to Django make this mistake.

@zachvalenta However, for me, 'Repetitive Paths' is not a problem at all. Some weeks ago, I took over a flask project that just like spaghetti, I almost want to kill myself. Then, I made a fake Django from Flask, and fake django-rest-framework is on the way.

Yensan avatar Jul 05 '19 12:07 Yensan

@zachvalenta sorry, but I have to say, that your blog post is totally wrong. Please take a look at https://docs.python-guide.org/writing/structure/#sample-repository for an correct example.

Some more words to clarify .. correct me if I'am wrong:

  1. The problem named in chapter "-Regarding Django Applications" is. that django creates <repo-foo>/<src-foo>/<py-pkg-foo> where all folders are named foo.

  2. The correct form from the example is <repo-foo>/<py-pkg-foo>

  3. In your blog post you recommend <repo-foo>/src

BTW: in your blog post the flask example is not true (anymore) and in your 'hope' section you say:

here are exceptions. pytest and Pillow both put their source code in, well, src."

.. please double check the projects you refer. E.g. pillow uses the src folder for C-sources and Py-sources, which is not common use case. There are so many bugs your blog post, confusing beginners .. please drop it.

return42 avatar Jul 05 '19 12:07 return42

.. please double check the projects you refer. E.g. pillow uses the src folder for C-sources and Py-sources, which is not common use case. There are so many bugs your blog post, confusing beginners .. please drop it.

@return42 Thank you. He just a nice guy and want to help... 'drop it' have some tone. Every one can keep his opinion.

Yensan avatar Jul 05 '19 13:07 Yensan

@kedod
thank you. But I build an fake django with Flask. Welcome to commit!!! https://github.com/Yensan/Schurz

Yensan avatar Aug 06 '19 14:08 Yensan