1
0
wiki/FormalSciences/ComputerScience/ProgrammingLanguage/Python/5.文化哲学/5.4-设计哲学.md
2024-10-13 20:52:05 +08:00

1.8 KiB

title description keywords tags author date
设计哲学 Python 的设计哲学
Python
设计哲学
Python/文化
技术/程序语言
7Wate 2022-10-18
# 运行此语句
# 控制台输出显示 Python 之禅
import this

The Zen of Python, by Tim Peters

Python 之禅,蒂姆·彼得斯 (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!

命名空间是个绝妙的主意,我们应好好利用它。