python program development directory specification

Better control of the standardization program structure, make the application more readable.

Project directory structure "actually belongs to the" category readability and maintainability, "we design a clear hierarchical directory structure, it is to achieve the following two points:

  1. High readability : not familiar with the code for this project people, one can understand the directory structure, which is known startup script, where the test directory, where the configuration file, and so on. So very fast about this project.

  2. High maintainability : The definition of a good organizational rules, defenders will be able to very clearly know which new files and code should be placed under any directory. The advantage is that, over time, the code / configuration size increases, the structure of the project will not be confused, still able to organize well.

So, keep a clear level directory structure is necessary.

On how to organize a good Python project directory structure, there are already some consensus has been the directory structure.

Assuming your project name is foo, the most convenient directory structure like this:

Foo/
|-- bin/
|   |-- foo
|
|-- foo/
|   |-- tests/
|   |   |-- __init__.py
|   |   |-- test_main.py
|   |
|   |-- __init__.py
|   |-- main.py
|
|--conf/
|  |-- __init__.py
|  |-- settings.py
|
|--logs/
|
|-- docs/
|   |-- conf.py
|   |-- abc.rst
|
|-- setup.py
|-- requirements.txt
|-- README

Simple explanation:

  1. bin/: Some items stored in executable files

  2. foo/: Store all the project's source code.

    (1) all the source code modules, packages should be placed in this directory. Do not put the top-level directory.

    (2) its sub- tests/storage unit test code;

    An inlet (3) program is preferably named main.py.

  3. conf/: Some items stored in the configuration file.

  4. logs/: Log information is stored in project implementation.

  5. docs/: Store some documents.

  6. setup.py: Installation, deployment, script packaged.

  7. requirements.txt: Python package store a list of external software dependencies.

  8. README: Project documentation.

README writing requirements:

It should be noted that the following matters:

  1. The basic functions of the software localization, software.

  2. The method of running code: installation environment, start commands.

  3. A brief description of the use.

  4. Code directory structure, a more detailed description can point the basic principles of software.

  5. Frequently asked questions.

In the early days of software development, because the development process is not clear or above may change, not necessarily to all the information will be complemented at the outset. But at the end of the project, is the need to write such a document.

Guess you like

Origin www.cnblogs.com/anttech/p/12594685.html