1 The Zen of Python, by Tim Peters 2
3 Beautiful is better than ugly. 4 Explicit is better than implicit. 5 Simple is better than complex. 6 Complex is better than complicated. 7 Flat is better than nested. 8 Sparse is better than dense. 9 Readability counts. 10 Special cases aren't special enough to break the rules.
11 Although practicality beats purity. 12 Errors should never pass silently. 13 Unless explicitly silenced. 14 In the face of ambiguity, refuse the temptation to guess. 15 There should be one-- and preferably only one --obvious way to do it. 16 Although that way may not be obvious at first unless you're Dutch.
17 Now is better than never. 18 Although never is often better than *right* now. 19 If the implementation is hard to explain, it's a bad idea.
20 If the implementation is easy to explain, it may be a good idea. 21 Namespaces are one honking great idea -- let's do more of those!
1 Beautiful is better than ugly. 2
3 # 優美勝於醜陋(Python以編寫優美的代碼爲目標)
4
5 Explicit is better than implicit. 6 # 明瞭勝於晦澀(優美的代碼應當是明瞭的,命名規範,風格類似)
7
8 Simple is better than complex. 9 # 簡潔勝於複雜(優美的代碼應當是簡潔的,不要有複雜的內部實現)
10
11 Complex is better than complicated. 12 # 複雜勝於凌亂(若是複雜不可避免,那代碼間也不能有難懂的關係,要保持接口簡潔)
13
14 Flat is better than nested. 15 # 扁平勝於嵌套(優美的代碼應當是扁平的,不能有太多的嵌套)
16
17 Sparse is better than dense. 18 # 間隔勝於緊湊(優美的代碼有適當的間隔,不要奢望一行代碼解決問題)
19
20 Readability counts. 21 # 可讀性很重要(優美的代碼是可讀的)
22
23 Special cases aren't special enough to break the rules.
24 Although practicality beats purity. 25 # 即使假借特例的實用性之名,也不可違背這些規則(這些規則至高無上)
26
27 Errors should never pass silently. 28 Unless explicitly silenced. 29 # 不要包容全部錯誤,除非你肯定須要這樣作(精準地捕獲異常,不寫except:pass風格的代碼)
30
31 In the face of ambiguity, refuse the temptation to guess. 32 # 當存在多種可能,不要嘗試去猜想
33
34 There should be one-- and preferably only one --obvious way to do it. 35 # 而是儘可能找一種,最好是惟一一種明顯的解決方案(若是不肯定,就用窮舉法)
36
37 Although that way may not be obvious at first unless you're Dutch.
38 # 雖然這並不容易,由於你不是 Python 之父(這裏的Dutch是指Guido)
39
40 Now is better than never. 41 Although never is often better than *right* now. 42 # 作也許好過不作,但不假思索就動手還不如不作(動手以前要細思量)
43
44 If the implementation is hard to explain, it's a bad idea.
45 If the implementation is easy to explain, it may be a good idea. 46 # 若是你沒法向人描述你的方案,那確定不是一個好方案;反之亦然(方案測評標準)
47
48 Namespaces are one honking great idea -- let's do more of those!
49 # 命名空間是一種絕妙的理念,咱們應當多加利用(倡導與號召)