Python之禅及释义
在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之禅及释义的更多相关文章
- python 之禅
想要真正深入了解一门语言,需要用心去感受.下面是python之禅,python的设计哲学,对于编程很有指导意义.(翻译部分摘自网络,同时自己有一些更改) >>> import thi ...
- Python的禅,“提姆彼得斯”说的非常有道理道出了这门编程语言的真谛!
The Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Simp ...
- Python之禅+八荣八耻
Python之禅 (The Zen of Python):是Python语言的指导原则,可以在Python命令行输入import this显示. import this >>> Th ...
- Python之禅及其翻译
凡是用过 Python的人,基本上都知道在交互式解释器中输入 import this 就会显示 Tim Peters 的 The Zen of Python,但它那偈语般的语句有点令人费解,所以我想分 ...
- Python自学:第二章 Python之禅
>>print import <Python之禅>,提姆·彼得斯著 美胜于丑. 显式优于隐式. 简单胜于复杂. 复杂总比复杂好. 平的比嵌套的好. 稀疏胜于稠密. 可读性计数. ...
- Python之禅的翻译和解释
The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit ...
- Python学习手册之 Python 之禅、Python 编程规范和函数参数
在上一篇文章中,我们介绍了 Python 的正则表达式使用示例,现在我们介绍 Python 之禅. Python 编程规范和函数参数.查看上一篇文章请点击:https://www.cnblogs.co ...
- (转)python之禅
凡是用过 Python的人,基本上都知道在交互式解释器中输入 import this 就会显示 Tim Peters 的 The Zen of Python,但它那偈语般的语句有点令人费解,所以我想分 ...
- 趣闻|Python之禅(The Zen of Python)
在Python解释器中输入“import this”会发生什么?如果你不知道这个彩蛋,推荐继续阅读这篇文章. 2001年秋,Foretec(一家会议组织公司)正在准备召开第十届Internationa ...
随机推荐
- springboot集成swagger
对于搬砖的同学来说,写接口容易,写接口文档很烦,接口变动,维护接口文档就更更更烦,所以经常能发现文档与程序不匹配. 等过一段时间就连开发者也蒙圈了 Swagger2快速方便的解决了以上问题.一个能与S ...
- SpringCache与redis集成,优雅的缓存解决方案
缓存可以说是加速服务响应速度的一种非常有效并且简单的方式.在缓存领域,有很多知名的框架,如EhCache .Guava.HazelCast等.Redis作为key-value型数据库,由于他的这一特性 ...
- tensorflow 安装升级
对于已经安装过的tensorflow,执行以下命令升级到最新版: pip3 install -U tensorflow 目前最新版本1.4
- 使用REST风格架构您需要知道的一些事
1. REST的由来 2. REST的构成 2.1. 资源 2.2. 资源的表述 2.2.1. MIME(Multipurpose Internet Mail Extensions) 2.2.2. 缓 ...
- 分享Sql Server 2008 r2 数据备份,同步服务器数据(一.本地备份)
最近在部署一个系统,处于数据安全的考虑,因此对相应的数据库服务器定时备份,以及数据同步到备份服务上.之前在另外的一个项目中也做过相应的操作,但是操作都是按照查找到的文章一步一步的操作,碰到一些细节问题 ...
- Scala并发编程react、loop代码实战具体解释
演示样例代码及凝视: //scala并发编程中的react和loop,共同特点: //通过线程存用的方式让性能有所提升. //Actor本身的运行,被actor子系统管理的时候,会有一个或者多个远程的 ...
- SharePoint Framework 简介
作者:陈希章 发表于 2017年12月25日 前言 通过前面几篇文章,我相信大家对于SharePoint Online的开发有了更加全面的认识,上一篇 介绍的SharePoint Add-in的开发, ...
- 关于Android中so解析那些事
1.Android系统目前支持的CPU架构:ARMv5.ARMv7.x86.MIPS.ARMv8.MIPS64.x86_64,每一种都关联着一个ABI(Application Binary Inter ...
- 一 、Spring Boot 学习之项目搭建
一.简介 spring 官方网站本身使用Spring 框架开发,随着功能以及业务逻辑的日益复杂,应用伴随着大量的XML配置文件以及复杂的Bean依赖关系. 随着Spring 3.0的发布,Spring ...
- 如何导入外部的源码到eclipse中
用struts,spring等框架开发也有两年的时间了,一直很少去阅读其源码,每次在eclipse编码的过程中想要看某一个类的源码,ctrl点击总是出现source not found的提示,也没有去 ...