Python之禅及释义

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

 

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

 

 1 >>> import this
 2 The Zen of Python, by Tim Peters
 3 
 4 Beautiful is better than ugly.
 5 Explicit is better than implicit.
 6 Simple is better than complex.
 7 Complex is better than complicated.
 8 Flat is better than nested.
 9 Sparse is better than dense.
10 Readability counts.
11 Special cases aren't special enough to break the rules.
12 Although practicality beats purity.
13 Errors should never pass silently.
14 Unless explicitly silenced.
15 In the face of ambiguity, refuse the temptation to guess.
16 There should be one-- and preferably only one --obvious way to do it.
17 Although that way may not be obvious at first unless you're Dutch.
18 Now is better than never.
19 Although never is often better than *right* now.
20 If the implementation is hard to explain, it's a bad idea.
21 If the implementation is easy to explain, it may be a good idea.
22 Namespaces are one honking great idea -- let's do more of those!

 

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

 1 >>> import this
 2 The Zen of Python, by Tim Peters
 3 #Python之禅, by Tim Perters
 4 
 5 Beautiful is better than ugly.
 6 #优美胜于丑陋
 7 Explicit is better than implicit.
 8 #明了胜于晦涩
 9 Simple is better than complex.
10 #简洁胜于复杂
11 Complex is better than complicated.
12 #复杂胜于凌乱
13 Flat is better than nested.
14 #扁平胜于嵌套
15 Sparse is better than dense.
16 #稀松胜于稠密
17 Readability counts.
18 #可读性很重要
19 Special cases aren't special enough to break the rules.
20 Although practicality beats purity.
21 #实用虽胜于纯粹
22 #但特例不足以改变原则(更多的时候特例并不是真的特例,而是你没发现更好的方案)
23 Errors should never pass silently.
24 #例外必须处理
25 Unless explicitly silenced.
26 #除非这正是你期望的
27 In the face of ambiguity, refuse the temptation to guess.
28 #当存在多种可能性,不要尝试去猜测
29 There should be one-- and preferably only one --obvious way to do it.
30 #而是尽量找一种,最好是唯一的一种,明确的方案
31 Although that way may not be obvious at first unless you're Dutch.
32 #虽然这不太容易,除非你是Python之父
33 Now is better than never.
34 #做好过不做
35 Although never is often better than *right* now.
36 #但不加思索的做,有时还不如不做
37 If the implementation is hard to explain, it's a bad idea.
38 #难以描述的方案,一定是个坏方案
39 If the implementation is easy to explain, it may be a good idea.
40 #易于描述的方案,可能是个好方案
41 Namespaces are one honking great idea -- let's do more of those!
42 #命名空间是绝妙的理念,我们应当多加利用

 

转载于:https://www.cnblogs.com/huahuayu/p/8111790.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值