python 之禪

來源:互聯網
上載者:User

標籤:cep   pac   special   you   ace   mil   one   rac   標準   

 1.Beautiful is better than ugly. 

優美勝於醜陋(Python以編寫優美的代碼為目標) 

2.Explicit is better than implicit.

 明了勝於晦澀(優美的代碼應當是明了的,命名規範,風格相似)

3. Simple is better than complex.

簡潔勝於複雜(優美的代碼應當是簡潔的,不要有複雜的內部實現)

4.Complex is better than complicated.

複雜勝於淩亂(如果複雜不可避免,那代碼間也不能有難懂的關係,要保持介面簡潔)

5.Flat is better than nested.

扁平勝於嵌套(優美的代碼應當是扁平的,不能有太多的嵌套)

6.Sparse is better than dense.

間隔勝於緊湊(優美的代碼有適當的間隔,不要奢望一行代碼解決問題)

7.Readability counts

可讀性很重要(優美的代碼是可讀的)

8.Special cases aren‘t special enough to break the rules. Although practicality beats purity.

 即便假借特例的實用性之名,也不可違背這些規則(這些規則至高無上)

9.Errors should never pass silently. Unless explicitly silenced.

不要包容所有錯誤,除非你確定需要這樣做(精準地捕獲異常,不寫except:pass風格的代碼)

10.In the face of ambiguity, refuse the temptation to guess.

當存在多種可能,不要嘗試去猜測

11.There should be one-- and preferably only one --obvious way to do it.24

而是盡量找一種,最好是唯一一種明顯的解決方案(如果不確定,就用窮舉法)

12.Although that way may not be obvious at first unless you‘re Dutch.

 雖然這並不容易,因為你不是 Python 之父(這裡的Dutch是指Guido)

13.Now is better than never。 Although never is often better than *right* now.

做也許好過不做,但不假思索就動手還不如不做(動手之前要細思量)

14.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.

如果你無法向人描述你的方案,那肯定不是一個好方案;反之亦然(方案測評標準)

15.Namespaces are one honking great idea -- let‘s do more of those!

命名空間是一種絕妙的理念,我們應當多加利用(倡導與號召)

python 之禪

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.