>>importthisTheZenofPython,byTimP" />

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

python之禪

系統 1592 0

起源

2001年秋召開第十屆International Python Conference(IPC 10,Pycon的前身),打算征集一條印在會議T恤衫上的標語,最終他們從Python社區收到了500多條投稿。并最中篩選確認為 import this ,他們選擇之后覺得需要實現它,經過討論最中定義為了由 Tim Peter 寫的《The zen of Python》

觸發

在交互命令中輸入 import this 就會觸發。

            
              
                >>
              
              
                >
              
              
                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!

            
          

譯文

            
              
                # 譯文 轉載
              
              
Beautiful 
              
                is
              
               better than ugly
              
                .
              
              
                # 優美勝于丑陋(Python以編寫優美的代碼為目標)
              
              

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
              
                .
              
              
                # 所有錯誤都不應該被直接忽略,除非能夠被精確的捕獲之后。(其中一個典型的例子就是,不建議用Exception:pass來直接忽略所有異常。)
              
              

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
              
                .
              
              
                # 雖然起初這并不那么顯而易見,因為你不是 Python 之父(這里的Dutch是指Python之父Guido Van Rossum,他是荷蘭人。)
              
              

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! 

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

更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 色综合久久一本首久久 | 午夜网站在线观看免费网址免费 | 亚洲天堂三级 | 日本欧美成人 | 狠狠五月婷婷 | 亚洲综合香蕉 | 日本不卡免免费观看 | 亚洲一区二区久久 | 伊人久久大香 | 日本aaaa精品免费视频 | 国产成人aa在线观看视频 | 国产精品久久久久久影院 | 免费在线一级片 | 国产99久久九九精品免费 | 国产精品欧美亚洲区 | 亚洲激情网站 | 中文字幕高清免费不卡视频 | 99热999 | 天堂成人一区二区三区 | 韩国亚洲伊人久久综合影院 | 欧美日韩a级片 | 午夜视频久久久久一区 | 欧美黄视频在线观看 | 国产亚洲欧美另类久久久 | 一区二区免费播放 | 午夜在线播放免费高清观看 | 久久精品在线免费观看 | 欧美一级特黄特黄毛片 | 日本一本一道久久香蕉免费 | 亚洲精品亚洲一区二区 | 国内精品久久久久影院一蜜桃 | 亚洲一区二区福利视频 | 国产精品视频免费一区二区三区 | 国产成人影院一区二区 | 成人人观看的免费毛片 | 色综合综合网 | 综合色网站| 精品一区二区三区免费视频 | 九九99久久精品午夜剧场免费 | 亚洲美女在线视频 | 国产成人精品免费视频 |