Google Python 编程规范指南
目录
GOOGLE PYTHON 编程规范指南 ............................................................................................................................ 1
目录 ............................................................................................................................................................................. 1
扉页 ............................................................................................................................................................................. 3
背景 ............................................................................................................................................................................. 3
PYTHON 语言规范 ........................................................................................................................................................ 4
LINT .................................................................................................................................................................................... 4
导入 .................................................................................................................................................................................. 5
包 ...................................................................................................................................................................................... 6
异常 .................................................................................................................................................................................. 7
全局变量 .......................................................................................................................................................................... 8
嵌套/局部/内部类或函数 ............................................................................................................................................... 9
列表推导(LIST COMPREHENSIONS) ........................................................................................................................................ 9
默认迭代器和操作符 .................................................................................................................................................... 11
生成器 ............................................................................................................................................................................ 12
LAMBDA 函数 ................................................................................................................................................................... 12
条件表达式 .................................................................................................................................................................... 13
默认参数值 .................................................................................................................................................................... 14
属性(PROPERTIES) .............................................................................................................................................................. 14
TRUE/FALSE 的求值 ........................................................................................................................................................... 16
过时的语言特性 ............................................................................................................................................................ 18
词法作用域(LEXICAL SCOPING) .......................................................................................................................................... 19
函数与方法装饰器 ........................................................................................................................................................ 20
线程 ................................................................................................................................................................................ 21
威力过大的特性 ............................................................................................................................................................ 21
分号 ................................................................................................................................................................................ 22
行长度 ............................................................................................................................................................................ 22
括号 ................................................................................................................................................................................ 23
缩进 ................................................................................................................................................................................ 24
空行 ................................................................................................................................................................................ 25
空格 ................................................................................................................................................................................ 25
SHEBANG ........................................................................................................................................................................... 26
注释 ................................................................................................................................................................................ 27
类 .................................................................................................................................................................................... 30
字符串 ............................................................................................................................................................................ 30
文件和 SOCKETS ................................................................................................................................................................ 32
TODO 注释 ..................................................................................................................................................................... 33
导入格式 ........................................................................................................................................................................ 33