7.1 Overriding Principle 最重要的原则 7.2 Descriptive: Naming Styles 描述:命名风格 7.3 Prescriptive: Naming Conventions 约定俗成:命名约定 7.4 Public and internal interfaces 公共和内部的接口 8. Programming Recommendations 编程建议 8.1 Function Annotations 功能注释 9. 参考 回到顶部 1. Introduction 介绍 本...
Cause naming conflicts because you might accidentally reuse a global name in different parts of your code, causing unexpected results Break encapsulation because global variables introduce hidden dependencies between different parts of your code Make your code hard to refactor because changes in one part...
Python Variable: This tutorial introduces the Python variable along with variable naming, assignment of a variable, local and global variables etc.
7. Naming Conventions 命名规范 7.1 Overriding Principle 最重要的原则 7.2 Descriptive: Naming Styles 描述:命名风格 7.3 Prescriptive: Naming Conventions 约定俗成:命名约定 7.4 Public and internal interfaces 公共和内部的接口 8. Programming Recommendations 编程建议 8.1 Function Annotations 功能注释 英文原文:PE...
__double_leading_underscore: when naming a class attribute, invokes name mangling (inside class FooBar, __boo becomes _FooBar__boo; see below). 1. __双下划线开头:模块内的成员,表示私有成员,外部无法直接调用 __double_leading_and_trailing_underscore__: "magic" objects or attributes that live ...
Internal: _GLOBAL_CONSTANT_NAME 二、应当避免的变量命名 (一)避免由单独一个字母组成的变量名 很多初学者,甚至有一些水平比较低的老师,都喜欢用a、b、c这种单个字母来给变量命名,这是不可取的。 因为这种变量名里面不包含任何信息,变量稍微多一点,程序稍微长一点,很容易就搞不清楚谁是谁、每个变量是干什么的了...
Prescriptive: Naming Conventions|规定性:命名约定 Names to Avoid|应避免使用的名字 永远不要将字符 'l'(小写字母 "el")、'O'(大写字母 "oh")或 'I'(大写字母 "eye")作为单个字符的变量名使用。 在某些字体中,这些字符与数字 1 和 0 难以区分。当有使用 'l' 的冲动时,请改用 'L'。
Because exceptions should be classes, the class naming convention applies here. However, you should use the suffix "Error" on your exception names (if the exception actually is an error). Global Variable Names (Let's hope that these variables are meant for use inside one module ...
Prescriptive Naming Conventions 约定俗成命名约定 Names to Avoid 应避免的名字 Package and Module Names 包名和模块名 Class Names 类名 Exception Names 异常名 Global Variable Names 全局变量名 Function Names 函数名 Function and method arguments 函数和方法参数 ...
这份文档为主Python发行版中标准库的Python代码提供了编码规范。请参阅相关的信息性PEP,该PEP描述了Python C实现中的C代码的样式指南。 这份文档和PEP 257(文档字符串规范)改编自Guido的原始Python样式指南文章,并加入了Barry样式指南的一些内容[2]。 随着额外的约定的发现和语言本身的变化使过去的约定变得过时,这个样...