1. 程式人生 > >Python之禪,亦是人生之禪

Python之禪,亦是人生之禪

eat nes info 骨感 better pre his 理想 copyright

C:\Users\Rage>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by 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!

Python之禪,蒂姆?彼得斯

美麗勝於醜陋。
顯式勝於隱式。
簡單勝於復雜。
復雜勝過繁復。
串行勝過嵌套。
稀疏勝過稠密。
可讀性很重要。
雖然理想很豐滿,現實很骨感,但是所謂特例並不足以打破上面的這些規則。
所有錯誤都不應該被直接忽略,除非能夠被精確的捕獲之後。(其中一個典型的例子就是,不建議用Exception:pass來直接忽略所有異常。)
面對歧義,拒絕猜測的誘惑。
應該有一種,最好是唯一一種,顯而易見的解決方案。
盡管起初,那種解決方案可能並不是那麽顯而易見,因為你不是Python 之父(這裏的Dutch是指Python之父Guido Van Rossum,他是荷蘭人。)
現在行動勝過永不開始。
盡管,永不開始經常好過沖動的開始。
如果你的實現難於向別人解釋,這往往不是個好主意。
如果你的實現很容易向別人解釋,這可能是個好主意。
命名空間是一個令人激動的偉大想法,讓我們將它發揚光大。

Python之禪,亦是人生之禪