Python 讀書筆記 (3) : Python 的禪意
The Zen of 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 之道 (POT 眾譯版)
美麗優於醜陋,明講好過暗諭。
簡潔者為上,複雜者次之,繁澀者為下。
平舖善於層疊,勻散勝過稠密;以致輕鬆易讀。
特例難免但不可打破原則,務求純淨卻不可不切實際。
斷勿使錯誤靜靜流逝,除非有意如此。
在模擬兩可之間,拒絕猜測的誘惑。
總會有一種明確的寫法,最好也只有一種,
但或須細想方可得。
凡事雖應三思後行,但坐而言不如起而行。
難以解釋的實作方式,必定是壞方法。
容易解釋的實作方式,可能是好主意。
命名空間讚,吾人多實用。
真好的意境!
我覺得, 這不單是寫Python程式時需要有這種心態, 而是所有的程式語言都應該效法, 不是嗎?!
簡明程式的撰寫, 命名的意喻都應該讓閱讀者有如在看白話文一般, 這樣程式碼才會被永久的留下來或重複的被採用, 我想這也是工程師在開源專案所抱持的心態以及夢寐以求的境界
簡明程式的撰寫, 命名的意喻都應該讓閱讀者有如在看白話文一般, 這樣程式碼才會被永久的留下來或重複的被採用, 我想這也是工程師在開源專案所抱持的心態以及夢寐以求的境界