pep8 && pep20

pep8(部分,遇到问题再补充)

1.不建议使用tab键来空格,避免不必要的空格。操作符左右各加一个空格,函数默认参数使用的赋值符左右省略空格。

2.类和top-level函数定义之间空两行;类中的方法定义之间空一行;函数内逻辑无关段落之间空一行;其他地方尽量不要再空行。

4.换行用反斜杠,建议用圆括号。

5.import部分,按标准、三方和自己编写顺序依次排放,之间空一行。

6.不建议在一句中import多个。

7.尽量用"is""is not"代替"=="

pep20

Beautiful is better than ugly.

Explicit is better than implicit.

Simple is better than complex.

Complex is better than complicated.

Flat is better than nested.

Sparse is better than dense.

Readability counts.

Special cases aren't special enough to break the rules.

Although practicality beats purity.

Errors should never pass silently.

Unless explicitly silenced.

In the face of ambiguity, refuse the temptation to guess.

There should be one-- and preferably only one --obvious way to do it.

Although that way may not be obvious at first unless you're Dutch.

Now is better than never.

Although never is often better than *right* now.

If the implementation is hard to explain, it's a bad idea.

If the implementation is easy to explain, it may be a good idea.

Namespaces are one honking great idea -- let's do more of those!

上一篇:React生命周期函数理解


下一篇:使用 Sublime、WebStorm 开发 Jade