The Zen of Python —— Python 之禅

谁践踏了优雅 2021-11-23 14:12 301阅读 0赞
  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. # 特殊情况不足以打破规则
  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. # 虽然那种方法一开始可能并不明显,除非你是 Dutch(Python 之父)
  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! # 命名空间是个绝妙的主意,让我们做更多这样的事

    注:在 Python 的交互式解释器中输入 import this 就可以查阅到上述文档。

转载于:https://www.cnblogs.com/dhqy/p/10874176.html

发表评论

表情:
评论列表 (有 0 条评论,301人围观)

还没有评论,来说两句吧...

相关阅读

    相关 python

    一次偶然的机会在一篇文档中(面试题),看到这样一个问题,问什么是python之禅,作为小白的我还真是不知道什么是python之禅,这里刚好看到一篇文章关于python之禅,借鉴