美文网首页
python编写规范

python编写规范

作者: 张一一 | 来源:发表于2016-01-14 19:42 被阅读36次

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.

相关文章

  • Python编写规范

    一、代码编排 二、文档编排 三、空格 四、注释 五、文档描述 六、命名规范 七、Main:即使是一个打算被用作脚本...

  • python编写规范

    1. No getters and setters. Use @property and @x.setter in...

  • python编写规范

    一、 说明 为了规范Python代码的书写,提高代码的可读性,使编码人员在代码上更好的协作,制定了本规范。 中...

  • Python编写规范

    一、编码:Python 3 源码文件以UTF-8编码,所有字符串都是 unicode 字符串 二、标识符:我们自己...

  • Python程序编写规范

    程序的编码风格是一个人编写程序时表现出来的特点、习惯逻辑思路等。我们在程序开发时要重视其编写规范,程序不仅应该能够...

  • 工具 | Python 篇 - 代码整洁之道 (2)

    写出 Pythonic 代码 谈到规范首先想到就是 Python 有名的 PEP8 代码规范文档,它定义了编写 P...

  • Python函数编写格式规范

    建议使用描述性名称来定义函数名。通过描述性名称,可以让我们很容易理解这个函数可以做什么。 函数名只使用小写字母与下...

  • pytest学习笔记

    使用环境 python3 pycharm pytest pytest编写规范 测试文件以test_开头或以_tes...

  • Python 编码规范(Style Guide)1

    在编写Python代码的时候,最好遵循Python 编码规范,这样,别人容易读懂你的代码,你也容易读懂别人的代码。...

  • 如何用 PEP 8 编写优雅的 Python 代码!

    教你怎么编写符合规范的Python代码,文章较长,请准备好咖啡 原文地址:How to Write Beautif...

网友评论

      本文标题:python编写规范

      本文链接:https://www.haomeiwen.com/subject/mqhhkttx.html