1. 程式人生 > 其它 >Python之禪( The Zen of Python )

Python之禪( The Zen of Python )

The Zen of Python, by Tim Peters

在控制檯上輸入

1.Python

2.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之父Guido。

現在開始做比什麼也不做強。

雖然什麼也不做永遠比不做更好。

如果實現方式很難去解釋,那這不是一個好的實現。

名稱空間是一個超好的機制,我們需要更多的使用。