<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-295  評論-26  文章-1  trackbacks-0

    在python中import this就會展示出The Zen of Python如下:


    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之禪,以下是翻譯


    Python之禪
    賴勇浩翻譯

    優美勝于丑陋(Python 以編寫優美的代碼為目標)
    明了勝于晦澀(優美的代碼應當是明了的,命名規范,風格相似)
    簡潔勝于復雜(優美的代碼應當是簡潔的,不要有復雜的內部實現)
    復雜勝于凌亂(如果復雜不可避免,那代碼間也不能有難懂的關系,要保持接口簡潔)
    扁平勝于嵌套(優美的代碼應當是扁平的,不能有太多的嵌套)
    間隔勝于緊湊(優美的代碼有適當的間隔,不要奢望一行代碼解決問題)
    可讀性很重要(優美的代碼是可讀的)
    即便假借特例的實用性之名,也不可違背這些規則(這些規則至高無上)
    不要包容所有錯誤,除非你確定需要這樣做(精準地捕獲異常,不寫 except:pass 風格的代碼)
    當存在多種可能,不要嘗試去猜測
    而是盡量找一種,最好是唯一一種明顯的解決方案(如果不確定,就用窮舉法)
    雖然這并不容易,因為你不是 Python 之父(這里的 Dutch 是指 Guido )
    做也許好過不做,但不假思索就動手還不如不做(動手之前要細思量)
    如果你無法向人描述你的方案,那肯定不是一個好方案;反之亦然(方案測評標準)
    命名空間是一種絕妙的理念,我們應當多加利用(倡導與號召)

     

    The Zen of Python,
    蛇宗三字經

    作者: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!
    每師出,多有名


    比較惡搞的是,其實 this 模塊的代碼完全違背了這些原則,為了方便你查看它的代碼,我把它貼出來:
    s = """Gur Mra bs Clguba, ol Gvz Crgref

    Ornhgvshy vf orggre guna htyl.
    Rkcyvpvg vf orggre guna vzcyvpvg.
    Fvzcyr vf orggre guna pbzcyrk.
    Pbzcyrk vf orggre guna pbzcyvpngrq.
    Syng vf orggre guna arfgrq.
    Fcnefr vf orggre guna qrafr.
    Ernqnovyvgl pbhagf.
    Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf.
    Nygubhtu cenpgvpnyvgl orngf chevgl.
    Reebef fubhyq arire cnff fvyragyl.
    Hayrff rkcyvpvgyl fvyraprq.
    Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.
    Gurer fubhyq or bar-- naq cersrenoyl bayl bar --boivbhf jnl gb qb vg.
    Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh'er Qhgpu.
    Abj vf orggre guna arire.
    Nygubhtu arire vf bsgra orggre guna *evtug* abj.
    Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg'f n onq vqrn.
    Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
    Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""

    d = {}
    for c in (65, 97):
        for i in range(26):
            d[chr(i+c)] = chr((i+13) % 26 + c)

    print "".join([d.get(c, c) for c in s])

    這段晦澀、復雜、凌亂的代碼,莫非是 Tim Peters 提供的反例?



    大盤預測 國富論
    posted on 2009-11-05 10:54 華夢行 閱讀(4815) 評論(0)  編輯  收藏 所屬分類: C
    主站蜘蛛池模板: 国产精品亚洲玖玖玖在线观看| 亚洲日韩精品无码专区网站| 亚洲AV无码1区2区久久| 一个人看的hd免费视频| 免费又黄又硬又爽大片| 亚洲男人天堂2020| 又粗又长又爽又长黄免费视频 | 国产区卡一卡二卡三乱码免费| 亚洲天堂2017无码中文| 性生交片免费无码看人| 亚洲日韩AV一区二区三区四区| 成年女人午夜毛片免费视频| 狠狠色婷婷狠狠狠亚洲综合| 无码人妻一区二区三区免费视频| 亚洲区不卡顿区在线观看| aa毛片免费全部播放完整| 成人性生交大片免费看无遮挡| 亚洲AV一二三区成人影片| 成人毛片18女人毛片免费| 亚洲一区二区无码偷拍| 免费永久在线观看黄网站| 国产99视频精品免费视频76| 成人超污免费网站在线看| 精品久久久久久亚洲中文字幕 | 亚洲欧洲视频在线观看| 青青久在线视频免费观看| 精品在线免费视频| www视频免费看| 在线亚洲人成电影网站色www| 亚洲乱妇老熟女爽到高潮的片| 四虎影视永久免费视频观看| 两性色午夜免费视频| 亚洲中文无码a∨在线观看| 白白国产永久免费视频| 亚洲中文字幕久在线| 亚洲精品动漫人成3d在线| 久久久久久影院久久久久免费精品国产小说| 尤物永久免费AV无码网站| 精品国产福利尤物免费| 亚洲国产精品综合久久网各| 国产免费131美女视频|