在 Python 的Lib目錄里有一個:this.Py (或者在互動式解釋器中輸入import this) 它其實是隱藏的一首詩 ...
在 Python 的Lib目錄里有一個:this.Py (或者在互動式解釋器中輸入import this) 它其實是隱藏的一首詩
The Zen of Python, by Tim Peters 《Python 的禪》 by 提姆·彼特 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! 命名空間是一個讓人尖呼的偉大構想 —— 我們應該在那方面做得更多!