python之禅

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python之禅相关的知识,希望对你有一定的参考价值。

参考技术A

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! 命名空间大法好,让我们多做些吧

Python之禅

>>> import this

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!



















以上是关于python之禅的主要内容,如果未能解决你的问题,请参考以下文章

Python之禅

Python之禅

Python之禅

python之禅

python之禅

python之禅