Code style. python-overall style. 0002. Make your Python program software catalog more standardized?

Source: Internet
Author: User

For what:

Description: The design directory structure and code coding style is the same as the personal style problem, but the normalization can better control program structure, so that the procedure has a higher readability, for how to organize a better directory structure, in the StackOverflow almost reached a consensus.


Directory structure:

Description: Assuming your project name is app, I would recommend the most convenient and quickest directory structure, as follows that is enough

. ├──app│├──__init__.py│├──main.py│└──tests│└──__init__.py├──bin├──changelog.txt├──docs│└──conf . py├──license.txt├──readme├──requirements.txt└──setup.py
Bin
Storing executable files in a project
App
Store all source code for the project
App/tests
Store Run unit test code
Doc
Store some documents
setup.py
Install, deploy, package scripts
Requirements.txt
Storage software relies on third-party packages, which can be automatically detected using Pigar
Readme
Project description File
LICENSE.txt
Open Source project agreement
ChangeLog.txt
Update Repair Record

Specific details:

1. The readme is the document that each project must have, the purpose is to let the reader quickly understand this project, should include the software localization, the basic function, the operation method, the use instruction, the catalogue explanation, frequently asked questions and so on, can refer to Redis's Readme file specifically

2. setup.py is used to manage code packaging, installation, deployment, industry standard is to use setuptools to manage these things, the main purpose is to be able to quickly and easily on a new machine to install the environment, code deployment and program run, the new environment is missing a dependency package can not start the problem is not uncommon, Setup.py can automate these things, improve efficiency, reduce error rates, automate complex things, automate things, and be a good habit.

3. Requirements.txt easy for developers to maintain the package dependencies of the software, add new packages in the development process to this list to avoid setup.py installation dependencies, if manually installed Pip-r Requirements.txt can quickly restore the project run environment

4. As above conf.py is not placed in the source code directory, but placed under the docs, strongly do not recommend that you put the configuration to write dead through the global import conf imports, which will make the module dependent on the external configuration unit testing becomes difficult, the program components can be reused too poor, So a better way to do this is to give a default configuration under Docs, specifying a configuration path with the main.py boot parameter to read the configuration content

This article is from the "ζ Automated operation and maintenance development Road ζ" blog, please be sure to keep this source http://xmdevops.blog.51cto.com/11144840/1856770

The

Code style. python-overall style. 0002. Make your Python program software catalog more normalized?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.