python编写规范

1.  No getters and setters.

Use @property and @x.setter instead

If u must use getters and setters as what u do in JAVA, use public property instead

2.  Properties should be low case and cancanated with '_' char.

3.  No interface and abstract though you can use abc module.

4.  All module names shoud be in low case.

5.  Use round brackets as many as possible.

6.  Multiple words in a function should be linked with underline char.

7.  Must have comments in every function describing every parameter and the return.

8.  Class names should be captilized words.

9.  Must not have semicolon to represent the end of the code line.

10.  __str__ should be rewrited as much as possible.

11.  There should be two lines before class definitions and one line between functions.

12.  Use four space as indent rather than a tab.

13.  If a class has no parent class, it should inherit from object class.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容