zoukankan      html  css  js  c++  java
  • Python之道 (大道至简)

    The Zen of Python

    1.       Beautiful is better than ugly.

    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.

    9.       Although practicality beats purity.

    10.   Errors should never pass silently.

    11.   Unless explicitly silenced.

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

    13.   There should be one— and preferably only one —obvious way to do it.

    14.   Although that way may not be obvious at first unless you're Dutch.

    15.   Now is better than never.

    16.   Although never is often better than right now.

    17.   If the implementation is hard to explain, it's a bad idea.

    18.   If the implementation is easy to explain, it may be a good idea.

    19.   Namespaces are one honking great idea — let's do more of those!

     (a poem by Tim Peters)

     

    · 优美胜于丑陋,

    · 明了胜于晦涩。

    · 简洁胜于复杂,

    · 复杂胜于凌乱。

    · 扁平胜于嵌套,

    · 稀疏胜于密繁。

    · 可读性很重要!

    · 即便假借特例的实用性之名,也不可违背这些规则。

    · 不要放过一切错误,除非错误本身需要以忽略对待。

    · 不确定面前,我们应抵挡妄加猜测的引诱。

    · 应该有一种,也但愿只有这一种是显而易见的解决之道。

    · 万事开头难,除非荷兰人。

    · 做好过不做,而不假思索就动手还不如不做。

    · 如果某个实现无法很好阐释,那么它肯定是一个糟糕的办法;

    · 如果某个实现很容易说清楚,那么它可能就是个不错的方案。

    · 命名空间是个绝妙的发明 —— 对此我们应多多益善!

     

    这些都是摘自网上 , 之所以特意发博 , 是因为用了好几年 python, 确实深深体会到他的优点 . 并对能写下这段话的 Tim Peters 表示深深敬意 , 大道至简 , 不光是用 python, 写任意程序 , 做任何事何尝不是这样 .

  • 相关阅读:
    〖Linux〗Kubuntu设置打开应用时就只在打开时的工作区显示
    〖Linux〗Kubuntu, the application 'Google Chrome' has requested to open the wallet 'kdewallet'解决方法
    unity, dll is not allowed to be included or could not be found
    android check box 自定义图片
    unity, ios skin crash
    unity, Collider2D.bounds的一个坑
    unity, ContentSizeFitter立即生效
    类里的通用成员函数应声明为static
    unity, Gizmos.DrawMesh一个坑
    直线切割凹多边形
  • 原文地址:https://www.cnblogs.com/fxjwind/p/2098643.html
Copyright © 2011-2022 走看看