Python 编程规范
1 简介.................................................................................................................................................2
2 源码缩进和排版.............................................................................................................................2
2.1 源码缩进..............................................................................................................................2
2.2 一行代码的最大长度..........................................................................................................2
2.3 空行......................................................................................................................................2
2.4 编辑器的设置......................................................................................................................3
2.5 编码格式..............................................................................................................................3
2.6 代码检查..............................................................................................................................3
3 注释.................................................................................................................................................4
3.1 注释块..................................................................................................................................4
3.2 行内注释..............................................................................................................................4
3.3 文档字符串..........................................................................................................................4
4 标识符命名.....................................................................................................................................4
4.1 命名风格..............................................................................................................................5
4.2 命名约定..............................................................................................................................5
4.3 模块名..................................................................................................................................5
4.4 类名......................................................................................................................................6
4.5 异常名..................................................................................................................................6
4.6 全局变量名..........................................................................................................................6
4.7 函数名..................................................................................................................................6
4.8 函数和方法参数..................................................................................................................6
5 模块导入.........................................................................................................................................6
6 表达式和语句.................................................................................................................................7
6.1 一般规则..............................................................................................................................7
6.2 其它建议..............................................................................................................................8
7 设计建议.........................................................................................................................................8