You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[> 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也知道爱是难言的-)
75
75
-[> Yes, it exists!](#-yes-it-exists)
76
76
-[> Inpinity *](#-inpinity-)
77
77
-[> Mangling time! *](#-mangling-time-)
@@ -1991,40 +1991,59 @@ True
1991
1991
- (译: 虽然文档中没写,但应该是只能在交互解释器中使用.)
1992
1992
---
1993
1993
1994
-
### > Even Python understands that love is complicated *
1994
+
### > Even Python understands that love is complicated/连Python也知道爱是难言的 *
1995
1995
1996
1996
```py
1997
1997
import this
1998
1998
```
1999
1999
2000
-
Wait, what's **this**? `this` is love :heart:
2000
+
等等, **this** 是什么? `this` 是爱 :heart:
2001
2001
2002
2002
**Output:**
2003
2003
```
2004
2004
The Zen of Python, by Tim Peters
2005
2005
2006
2006
Beautiful is better than ugly.
2007
+
优美胜于丑陋(Python 以编写优美的代码为目标)
2007
2008
Explicit is better than implicit.
2009
+
明了胜于晦涩(优美的代码应当是明了的,命名规范,风格相似)
2008
2010
Simple is better than complex.
2011
+
简洁胜于复杂(优美的代码应当是简洁的,不要有复杂的内部实现)
2009
2012
Complex is better than complicated.
2013
+
复杂胜于凌乱(如果复杂不可避免,那代码间也不能有难懂的关系,要保持接口简洁)
2010
2014
Flat is better than nested.
2015
+
扁平胜于嵌套(优美的代码应当是扁平的,不能有太多的嵌套)
2011
2016
Sparse is better than dense.
2017
+
间隔胜于紧凑(优美的代码有适当的间隔,不要奢望一行代码解决问题)
2012
2018
Readability counts.
2019
+
可读性很重要(优美的代码一定是可读的)
2013
2020
Special cases aren't special enough to break the rules.
2021
+
没有特例特殊到需要违背这些规则(这些规则至高无上)
2014
2022
Although practicality beats purity.
2023
+
尽管我们更倾向于实用性
2015
2024
Errors should never pass silently.
2025
+
不要安静的包容所有错误
2016
2026
Unless explicitly silenced.
2027
+
除非你确定需要这样做(精准地捕获异常,不写 except:pass 风格的代码)
2017
2028
In the face of ambiguity, refuse the temptation to guess.
2029
+
拒绝诱惑你去猜测的暧昧事物
2018
2030
There should be one-- and preferably only one --obvious way to do it.
2031
+
而是尽量找一种,最好是唯一一种明显的解决方案(如果不确定,就用穷举法)
2019
2032
Although that way may not be obvious at first unless you're Dutch.
2033
+
虽然这并不容易,因为你不是 Python 之父(这里的 Dutch 是指 Guido )
2020
2034
Now is better than never.
2035
+
现在行动好过永远不行动
2021
2036
Although never is often better than *right* now.
2037
+
尽管不行动要好过鲁莽行动
2022
2038
If the implementation is hard to explain, it's a bad idea.
2039
+
如果你无法向人描述你的方案,那肯定不是一个好方案;
2023
2040
If the implementation is easy to explain, it may be a good idea.
2041
+
如果你能轻松向人描述你的方案,那也许会是一个好方案(方案测评标准)
2024
2042
Namespaces are one honking great idea -- let's do more of those!
2043
+
命名空间是一种绝妙的理念,我们应当多加利用(倡导与号召)
2025
2044
```
2026
2045
2027
-
It's the Zen of Python!
2046
+
这是 Python 之禅!
2028
2047
2029
2048
```py
2030
2049
>>> love = this
@@ -2036,15 +2055,16 @@ False
2036
2055
False
2037
2056
>>> love is not True or False
2038
2057
True
2039
-
>>> love is not True or False; love is love # Love is complicated
2058
+
>>> love is not True or False; love is love # 爱是难言的
2040
2059
True
2041
2060
```
2042
2061
2043
-
#### 💡 Explanation:
2062
+
#### 💡 说明:
2044
2063
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.
0 commit comments