Python Software directory structure specification

Source: Internet
Author: User

Software Catalog Structure specificationSoftware Development SpecificationsWhy should we design a directory structure?

1. High readability: People who are unfamiliar with the code of this project can read the directory structure at a glance, know which program startup script is, where the test directory is, where the configuration file is, and so on. To get to know this project very quickly.

2. High maintainability: Once you have defined your organization's rules, the maintainer will be able to know exactly what directory the new file and code should be placed in. The benefit is that as time goes on, the size of the code/configuration increases and the project structure is not cluttered and can still be well organized.

Ii. Directory Organization mode

There are already some common directory structures for how to organize a better Python project directory structure.

Let's say your project is named ATM

ATM/|-- bin/    存放项目的一些可执行文件,当然你可以起名script/之类的也行,但bin/更直观。易懂|   |-- __init__
|  |-- start.py 写启动程序||-- core/ 存放项目的所有源代码(核心代码)。(1) 源代码中的所有模块、包都应该放在此目录。不要置于顶层目录。 (2) 其子目录tests/存放单元测试代码; (3) 程序的入口最好命名为main.py
| |-- tests/
| | |-- __init__.py
| | |-- test.main.py
| || |-- __init__.py| |-- test_main.py| 存放核心逻辑 ||-- conf/ 配置文件| |-- __init__.py| |-- setting.py 写上相关配置
|
|---db/ 数据库文件| |--db.json 写数据库文件
| |-- docs/ 存放一些文档
| |-- lib/ 库文件,放自定义模块和包
| |-- __init__.py
| |-- common.py 放常用的功能
|
|-- log/ 日志文件
| |-- access.log 写上日志
|
|-- __init__.py|-- README 项目说明文件

注:运行程序时,在bin目录下执行start.py代码,不可以直接执行core下的模块。



about the content of the Readme

This is a document that I think should be available for each project, with the aim of briefly describing the project's information and giving the reader a quick overview of the project.

It needs to illustrate several things:

    1. Software positioning, the basic functions of the software.
    2. How to run your code: Installation environment, startup commands, and so on.
    3. Brief instructions for use.
    4. Code directory structure Description, more detailed can explain the basic principles of the software.
    5. FAQ's description.

Python Software directory structure specification

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.