Python 语言之禅:
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 社区所推崇的许多理念,如:
- 优美优于丑陋
- 明确优于暗示
- 简单优于复杂
- 复杂优于晦涩
- 平直优于嵌套
- 宽松优于密集
- 可读性很重要
- 特殊情况没有特殊规则
- 实用性胜于纯粹性
- 错误不能悄悄地通过
- 需要明确地声明抑制错误
- 面对模棱两可,拒绝猜测
- 应当有一种,且最好是仅有一种,显而易见的写法
- 现在开始做优于稍后尝试做
- 尽管后者常常比前者好,但“不做”通常比“随意做”更好
- 如果实现很难解释,那它就是个坏主意
- 如果实现容易解释,那它可能是个好主意
- 命名空间是个非常好的想法,请多加支持
本文可能转载于网络公开资源,如果侵犯您的权益,请联系我们删除。
0