Skip to content

Commit 90383b2

Browse files
author
ducheng
committed
EX.Even Python understands that love is complicated
1 parent 42ee91c commit 90383b2

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ So, here we go...
7171
- [> `goto`, but why?/`goto`, 但为什么? *](#-goto-but-whygoto-但为什么-)
7272
- [> Brace yourself!/做好思想准备 *](#-brace-yourself做好思想准备-)
7373
- [> Let's meet Friendly Language Uncle For Life/让生活更友好 *](#-lets-meet-friendly-language-uncle-for-life让生活更友好-)
74-
- [> Even Python understands that love is complicated *](#-even-python-understands-that-love-is-complicated-)
74+
- [> Even Python understands that love is complicated/连Python也知道爱是难言的 *](#-even-python-understands-that-love-is-complicated连Python也知道爱是难言的-)
7575
- [> Yes, it exists!](#-yes-it-exists)
7676
- [> Inpinity *](#-inpinity-)
7777
- [> Mangling time! *](#-mangling-time-)
@@ -1991,40 +1991,59 @@ True
19911991
- (译: 虽然文档中没写,但应该是只能在交互解释器中使用.)
19921992
---
19931993
1994-
### > Even Python understands that love is complicated *
1994+
### > Even Python understands that love is complicated/连Python也知道爱是难言的 *
19951995
19961996
```py
19971997
import this
19981998
```
19991999
2000-
Wait, what's **this**? `this` is love :heart:
2000+
等等, **this** 是什么? `this` 是爱 :heart:
20012001
20022002
**Output:**
20032003
```
20042004
The Zen of Python, by Tim Peters
20052005
20062006
Beautiful is better than ugly.
2007+
优美胜于丑陋(Python 以编写优美的代码为目标)
20072008
Explicit is better than implicit.
2009+
明了胜于晦涩(优美的代码应当是明了的,命名规范,风格相似)
20082010
Simple is better than complex.
2011+
简洁胜于复杂(优美的代码应当是简洁的,不要有复杂的内部实现)
20092012
Complex is better than complicated.
2013+
复杂胜于凌乱(如果复杂不可避免,那代码间也不能有难懂的关系,要保持接口简洁)
20102014
Flat is better than nested.
2015+
扁平胜于嵌套(优美的代码应当是扁平的,不能有太多的嵌套)
20112016
Sparse is better than dense.
2017+
间隔胜于紧凑(优美的代码有适当的间隔,不要奢望一行代码解决问题)
20122018
Readability counts.
2019+
可读性很重要(优美的代码一定是可读的)
20132020
Special cases aren't special enough to break the rules.
2021+
没有特例特殊到需要违背这些规则(这些规则至高无上)
20142022
Although practicality beats purity.
2023+
尽管我们更倾向于实用性
20152024
Errors should never pass silently.
2025+
不要安静的包容所有错误
20162026
Unless explicitly silenced.
2027+
除非你确定需要这样做(精准地捕获异常,不写 except:pass 风格的代码)
20172028
In the face of ambiguity, refuse the temptation to guess.
2029+
拒绝诱惑你去猜测的暧昧事物
20182030
There should be one-- and preferably only one --obvious way to do it.
2031+
而是尽量找一种,最好是唯一一种明显的解决方案(如果不确定,就用穷举法)
20192032
Although that way may not be obvious at first unless you're Dutch.
2033+
虽然这并不容易,因为你不是 Python 之父(这里的 Dutch 是指 Guido )
20202034
Now is better than never.
2035+
现在行动好过永远不行动
20212036
Although never is often better than *right* now.
2037+
尽管不行动要好过鲁莽行动
20222038
If the implementation is hard to explain, it's a bad idea.
2039+
如果你无法向人描述你的方案,那肯定不是一个好方案;
20232040
If the implementation is easy to explain, it may be a good idea.
2041+
如果你能轻松向人描述你的方案,那也许会是一个好方案(方案测评标准)
20242042
Namespaces are one honking great idea -- let's do more of those!
2043+
命名空间是一种绝妙的理念,我们应当多加利用(倡导与号召)
20252044
```
20262045
2027-
It's the Zen of Python!
2046+
这是 Python 之禅!
20282047
20292048
```py
20302049
>>> love = this
@@ -2036,15 +2055,16 @@ False
20362055
False
20372056
>>> love is not True or False
20382057
True
2039-
>>> love is not True or False; love is love # Love is complicated
2058+
>>> love is not True or False; love is love # 爱是难言的
20402059
True
20412060
```
20422061
2043-
#### 💡 Explanation:
2062+
#### 💡 说明:
20442063
2045-
* `this` module in Python is an easter egg for The Zen Of Python ([PEP 20](https://www.python.org/dev/peps/pep-0020)).
2046-
* And if you think that's already interesting enough, check out the implementation of [this.py](https://hg.python.org/cpython/file/c3896275c0f6/Lib/this.py). Interestingly, the code for the Zen violates itself (and that's probably the only place where this happens).
2047-
* Regarding the statement `love is not True or False; love is love`, ironic but it's self-explanatory.
2064+
* `this` 模块是关于 Python 之禅的复活节彩蛋 ([PEP 20](https://www.python.org/dev/peps/pep-0020)).
2065+
* 如果你认为这已经够有趣的了, 可以看看 [this.py](https://hg.python.org/cpython/file/c3896275c0f6/Lib/this.py) 的实现. 有趣的是, Python 之禅的实现代码违反了他自己 (这可能是唯一会发生这种情况的地方).
2066+
*
2067+
至于 `love is not True or False; love is love`, 意外却又不言而喻.
20482068
20492069
---
20502070

0 commit comments

Comments
 (0)