Python之禪 The Zen of Pytho
by Tim Peters
?
Beautiful is better than ugly. 優(yōu)美勝于丑陋。
?
Explicit is better than implicit. 直白勝于晦澀。
?
Simple is better than complex. 簡(jiǎn)潔勝于復(fù)雜。部結(jié)構(gòu))
?
Complex is better than complicated. 復(fù)雜勝于凌亂。
?
Flat is better than nested. 扁平勝于嵌套。
?
Sparse is better than dense. 間隔勝于緊湊。
?
Readability counts. 可讀性很重要。
?
Special cases aren't special enough to break the rules. 再怎么特殊,也不能特殊到違背這些規(guī)則。
?
Although practicality beats purity. 即便如此,實(shí)用比純潔更重要。
?
Errors should never pass silently. Unless explicitly silenced. 不要放過(guò)任何錯(cuò)誤,除非你確定需要這樣做。
?
In the face of ambiguity, refuse the temptation to guess. 當(dāng)存在多種可能時(shí),不要靠猜。
?
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. 雖然這并不容易,因?yàn)槟悴皇?Python 之父(這里的 Dutch 是指 Guido )
?
Now is better than never.
Although never is often better than *right* now. 做也許好過(guò)不做,但不假思索就動(dòng)手還不如不做。
?
If the implementation is hard to explain, it's a bad idea. 如果你無(wú)法向人描述你的方案,那肯定不是一個(gè)好方案。
If the implementation is easy to explain, it may be a good idea. 如果你的方案很容易向人描述,那么有可能就是個(gè)好方案,
?
Namespaces are one honking great idea -- let's do more of those! 命名空間是一種絕妙的理念,我們應(yīng)當(dāng)多加利用。