PEP20(python之禅)
PEP20是编写python程序的指导准则,在python shell中输入import this就能看到
英文版:
The Zen of Python, by Tim Peters
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!
中文版:
TIM Peters的python之禅
优美胜于丑陋。
明确胜于隐晦。
简单胜于复杂。
复杂胜于难懂。
扁平胜于嵌套。
留白胜于紧凑。
可读性很重要。
特例也并不能特殊到可以违背这些原则。
虽然实用性胜于纯粹性。
错误不应被默默地忽略。
除非你明确地忽视。
面对歧义,不要尝试去猜测。
应该有一种——最好是仅有一种——明显的处理方式。
一开始那种方式并非显而易见,除非你是python之父。
做好过不做。
不假思索就动手还不如不做。
如果实现很难解释,那就不是个好思路。
如果实现易于解释,则可能是个好思路。
命名空间是个绝妙的主意,我们要多多利用它。

浙公网安备 33010602011771号