在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. Axios 执行post发送两次请求的小坑

    vue-resource2.0已经不再更新,所以vue2.0官方推荐使用axios来代替.实际项目也是应用上了vue+axios,然后就有了这么一段填坑的经历. 问题:axios使用post请求时,发 ...

  2. 中文编程语言之Z语言初尝试: ZLOGO 4

    原文: https://zhuanlan.zhihu.com/p/31505895. 作者为本人. @TKT2016 开发的Z语言(ZLOGO是它的一个部分)是本人至今看到的唯一一个仍活跃开发的开源且 ...

  3. video视频铺满

    1. 因项目需求,要在公司官网加一段视频,达到的效果是视频平铺整个网页,大小随网页变化:网上找了许久才找了了这么一个生僻的属性,只需给video加这么个样式就可以了:object-fit: fill; ...

  4. .NET Core 快速入门教程

    .NET Core 快速学习.入门系列教程.这个入门系列教程主要跟大家聊聊.NET Core的前世今生,以及Windows.Linux(CentOS.Ubuntu)基础开发环境的搭建.第一个.NET ...

  5. 关于Oracle处理DDL和DML语句的事务管理

    SQL主要程序设计语言 数据定义语言DDL(Data Definition Language) 如 create.alter.drop, 数据操作语言DML(Data Munipulation Lan ...

  6. netty开发教程(一)

    Netty介绍 Netty is an asynchronous event-driven network application framework  for rapid development o ...

  7. 蓝牙核心技术概述(五):蓝牙协议规范(irOBEX、BNEP、AVDTP、AVCTP)

    关键词:蓝牙核心技术协议  irDA BNEP  AVDTP AVCTP 作者:xubin341719(欢迎转载,请注明作者,请尊重版权,谢谢! )欢迎指正错误,共同学习.共同进步!! 下载链接:Bl ...

  8. JAVA入门[6]-Mybatis简单示例

    初次使用Mybatis,先手写一个hello world级别的例子,即根据id查询商品分类详情. 一.建表 create table Category ( Id INT not null, Name ...

  9. Tomcat配置(二):tomcat配置文件server.xml详解和部署简介

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  10. 带你深度解析Maven

    一.What`s Maven? Maven是基于项目对象模型(POM project object model),可以通过一小段描述信息(配置)来管理项目的构建,报告和文档的软件项目管理工具,简单的说 ...