官术网_书友最值得收藏!

1.3 The Zen of Python

開始正式學(xué)習(xí)本書的最后一個準(zhǔn)備工作,便是對這門編程語言的藝術(shù)有一個了解。打開IPython,輸入import this。這些輸出的內(nèi)容要始終銘記于心。

    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之禪
    優(yōu)美勝于丑陋
    明確勝于隱晦
    簡單勝于復(fù)雜
    復(fù)雜勝于凌亂
    扁平勝于嵌套
    稀疏勝于緊湊
    可讀性至關(guān)重要
    即便特例,也需服從以上規(guī)則
    除非刻意追求,錯誤不應(yīng)跳過
    面對歧義條件,拒絕嘗試猜測
    解決問題的最優(yōu)方法應(yīng)該有且只有一個
    盡管這一方法并非顯而易見(除非你是Python之父)
    動手勝于空想
    空想勝于不想
    難以解釋的實現(xiàn)方案,不是好方案
    易于解釋的實現(xiàn)方案,才是好方案
    命名空間是個絕妙的理念,多多益善!
主站蜘蛛池模板: 治多县| 开原市| 平顶山市| 加查县| 龙江县| 吕梁市| 开平市| 大理市| 桃园县| 镶黄旗| 宿迁市| 海门市| 东平县| 江达县| 富平县| 盐池县| 嘉义市| 兖州市| 蕲春县| 霍州市| 读书| 彰化县| 张家界市| 茌平县| 藁城市| 平顺县| 黑水县| 淮滨县| 盘锦市| 澜沧| 女性| 夏津县| 渭源县| 漳州市| 九龙城区| 田阳县| 常山县| 盈江县| 曲周县| 通河县| 修武县|