Module 03 · [Optional] Python Coding Practices and Packaging Concepts(可选)Python 编码实践与打包概念
Module Introduction模块介绍
Once you start developing proficiency with Python, it becomes important to create codes that comply to accepted standard guidelines and that are efficient in their approach. This can be achieved by following the PEP8 guidelines, which serve as the standard for all kinds of coding processes, from simple programs to complex software codes.
一旦您开始熟练掌握 Python,创建符合公认标准指南且方法高效的代码就变得非常重要。这可以通过遵循 PEP8 指南来实现,该指南是所有编码过程的标准,从简单的程序到复杂的软件代码。
Compliance to these guidelines can be tested using static code analysis. Libraries like PyLint in Python are often used to check the compliance of codes to the PEP8 guidelines.
可以使用静态代码分析来测试这些指南的符合性。Python 中的 PyLint 等库通常用于检查代码对 PEP8 指南的符合性。
When creating functions to perform specific tasks in a project, it is a good practice to test their efficacy using unit testing. Unit testing is an essential part of many system design processes since it protects against deployment of an incorrectly made function in practical applications.
在项目中创建函数以执行特定任务时,使用单元测试来测试其有效性是一种很好的做法。单元测试是许多系统设计过程中必不可少的一部分,因为它可以防止在实际应用中部署不正确制作的函数。
Lastly, in attempts to create typical code functions, that can be used by anyone for their own specific purposes, it is a good coding practice to create packages in Python that can be then imported to any file in the project.
最后,为了创建任何人都可以用于其特定目的的典型代码函数,在 Python 中创建包是一种良好的编码实践,然后可以将这些包导入到项目中的任何文件。
In this module you learn all these principles in order to enhance your coding abilities. Please note that this module is entirely optional and has no bearing to your grade in the course. This is mainly for your knowledge enhancement and to improve your abilities as a Python programmer.
在本模块中,您将学习所有这些原则,以提高您的编码能力。请注意,本模块完全是可选的,对您在本课程中的成绩没有影响。这主要是为了增长您的知识,提高您作为一名 Python 程序员的能力。