在python shell中敲 import this会触发一个彩蛋,神奇的打印下面一段话:

The Zen of Python, 即python之禅, 1999年Tim Peters大牛总结的“武功心法”:

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

我在网上参考了别人的翻译,再结合我自己的理解翻译如下:

 >>> import this
The Zen of Python, by Tim Peters
#Python之禅, by Tim Perters 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.
#虽然这不太容易,除非你是Python之父
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之禅及释义的更多相关文章

  1. python 之禅

    想要真正深入了解一门语言,需要用心去感受.下面是python之禅,python的设计哲学,对于编程很有指导意义.(翻译部分摘自网络,同时自己有一些更改) >>> import thi ...

  2. Python的禅,“提姆彼得斯”说的非常有道理道出了这门编程语言的真谛!

    The Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Simp ...

  3. Python之禅+八荣八耻

    Python之禅 (The Zen of Python):是Python语言的指导原则,可以在Python命令行输入import this显示. import this >>> Th ...

  4. Python之禅及其翻译

    凡是用过 Python的人,基本上都知道在交互式解释器中输入 import this 就会显示 Tim Peters 的 The Zen of Python,但它那偈语般的语句有点令人费解,所以我想分 ...

  5. Python自学:第二章 Python之禅

    >>print import <Python之禅>,提姆·彼得斯著 美胜于丑. 显式优于隐式. 简单胜于复杂. 复杂总比复杂好. 平的比嵌套的好. 稀疏胜于稠密. 可读性计数. ...

  6. Python之禅的翻译和解释

      The Zen of Python, by Tim Peters   Beautiful is better than ugly. Explicit is better than implicit ...

  7. Python学习手册之 Python 之禅、Python 编程规范和函数参数

    在上一篇文章中,我们介绍了 Python 的正则表达式使用示例,现在我们介绍 Python 之禅. Python 编程规范和函数参数.查看上一篇文章请点击:https://www.cnblogs.co ...

  8. (转)python之禅

    凡是用过 Python的人,基本上都知道在交互式解释器中输入 import this 就会显示 Tim Peters 的 The Zen of Python,但它那偈语般的语句有点令人费解,所以我想分 ...

  9. 趣闻|Python之禅(The Zen of Python)

    在Python解释器中输入“import this”会发生什么?如果你不知道这个彩蛋,推荐继续阅读这篇文章. 2001年秋,Foretec(一家会议组织公司)正在准备召开第十届Internationa ...

随机推荐

  1. [置顶] Java WebService接口生成和调用 图文详解

    webservice简介: Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的.专门的第三方软件或硬件, 就可相互交换数据或集成.依据Web Service规范实施的应用之间 ...

  2. C++反汇编第六讲,认识C++中的Try catch语法,以及在反汇编中还原

    C++反汇编第六讲,认识C++中的Try catch语法,以及在反汇编中还原 我们以前讲SEH异常处理的时候已经说过了,C++中的Try catch语法只不过是对SEH做了一个封装. 如果不懂SEH异 ...

  3. ssm开发关于web.xml配置

    <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...

  4. Linux权限相关操作命令

    以下是关于创建用户,设置用户密码,以及查看文件权限,给用户设置权限的一系列操作过程. #查看当前用户的信息[root@VM_64_7_centos tmp]# iduid=0(root) gid=0( ...

  5. OpenCV探索之路(二十八):Bag of Features(BoF)图像分类实践

    在深度学习在图像识别任务上大放异彩之前,词袋模型Bag of Features一直是各类比赛的首选方法.首先我们先来回顾一下PASCAL VOC竞赛历年来的最好成绩来介绍物体分类算法的发展. 从上表我 ...

  6. Spring3.0官网文档学习笔记(二)

    1.3 使用场景 典型的成熟的spring web应用 spring使用第三方框架作为中间层 远程使用场景 EJB包装 1.3.1 依赖管理.命名规则(包)     spring-*.jar *号代表 ...

  7. 【LDA】修正 GibbsLDA++-0.2 中的两个内存问题

    周末这两天在家用LDA做个小实验. 在LDA的众多实现的工具包中.GibbsLDA 是应用最广泛的.包含c++版本号.java版本号等.GibbsLDA++ 是它的C++版本号的实现.眼下最新版本号是 ...

  8. ElasticSearch和ElasticSearch Head环境搭建和数据模拟

    首先elasticsearch-6.0.0\bin目录下运行elasticsearch服务 修改elasticsearch-6.0.0\elasticsearch.yml文件 在文件最后加入下面代码, ...

  9. 关于MySql中使用IFNULL()函数失效的问题。

    今天在学习时,碰到一个问题:在联表查询取得结果后,如果取得的结果是空值,则给一个默认值,如果不是空值,则返回这个值. 下面我们来看看业务场景: 在menu表中: 存储的是前端页面的菜单配置,注意成员权 ...

  10. angular自定义分页组件(实用)

    功能描述:分页,点击按钮或者下一页获取分页接口,同时active到对应页码. html模块: <page page-count="totalPage" on-click-pa ...