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 ...
随机推荐
- 纯css美化单选、复选框
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 完整教程--idea使用git进行项目管理
第一部分: 安装 1. 下载地址: https://git-scm.com/download/win; 如果速度慢, 使用 迅雷下载; 2. 点击安装, 然后下一步, 直到下面这个页面: 建议: 按 ...
- System.ServiceModel.CommunicationException: 已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。
- NGUI_概述
序言:这是张三疯第一次开始NGUI插件的学习,刚开始学习,肯定有很多漏洞,后期会及时的补上的. 希望大家可以见谅,希望大佬多多指教. 一.什么是NGUI: NGUI是严格遵循KISS原则并用C#编写的 ...
- canvas 从初级到XX 1# 部分非基础原生API的使用 [初级向]
标题canvas 从初级到XX,XX是因为本文随机都可能会太监,并不会支持到入土.请慎重的往下看. 对于canvas的介绍,随处都可以找到,也就不啰嗦太多了.就直奔主题了. 先看一段代码,以及实现的效 ...
- SharePoint 2010 Url Shortener --SharePoint 2010 短URL生成器
SharePoint 2010 Url Shortener --SharePoint 2010 短URL生成器 项目描写叙述 本项目加入了这种功能.在SP站点中能够生成短URLs. 这些URLs指向列 ...
- Property list types and their various representations
iOS下Property list能够存储的数据类型 Property list types and their various representations Abstract type XML ...
- 单行json_ajax
html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...
- OVS 总体架构、源码结构及数据流程全面解析
在前文「从 Bridge 到 OVS」中,我们已经对 OVS 进行了一番探索.本文决定从 OVS 的整体架构到各个组件都进行一个详细的介绍. OVS 架构 OVS 是产品级的虚拟交换机,大量应用在生产 ...
- 二.java下使用RabbitMQ实现hello world
上一篇文章介绍了windows环境下的安装和配置rabbitMQ,具体戳这边,一.windows环境下rabbit的的安装和配置. 现在我们可以着手编写hello world程序了,一窥RabbitM ...