用于 Python 开发的文件夹和文件组织

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1642975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 22:47:11  来源:igfitidea点击:

Folder and file organization for Python development

pythonorganizationcode-organization

提问by George Silva

What is the best way to organize code that belongs to the same project in a Python development environment? What are the do and donts of Python project organization? Do you separate each class in a file?

在 Python 开发环境中组织属于同一项目的代码的最佳方法是什么?Python 项目组织的注意事项是什么?您是否将每个类分开放在一个文件中?

Project A
   Classes
       "subsystem1"
           class1
           class2
           subsystem1Module
       "subsystem2"
       "utils"
       "etc"
   Tests
   Whatever
   etc?

Any suggestions? Oh, and please describe what are the (possible) problems of each type of organization.

有什么建议?哦,请描述每种类型的组织的(可能的)问题是什么。

What are considered best practices for organizing Python code?

组织 Python 代码的最佳实践是什么?

回答by Tendayi Mawushe

There are not that many issues that are going to be applicable only to Python. This website: Software Configuration Management Patternsand the associate book describes some Source Code Management patterns.

没有多少问题只适用于 Python。这个网站:软件配置管理模式和相关的书描述了一些源代码管理模式。

The issues are described in the familiar patterns language so you should be able to find the information you need for your requirements. As with all patterns there is also discussion on the trade-offs.

这些问题是用熟悉的模式语言描述的,因此您应该能够找到满足您需求的信息。与所有模式一样,也有关于权衡的讨论。