都知道Zen of Python, 這里還是重復一下填抬。由于這篇東西還真是在vim中寫的,可以利用vim的能力霉旗,在vim的命令模式下輸入:
:read !echo import this | python
得到下面的輸出:
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!
自己翻譯一下:
Python之禪
美麗勝過丑陋
明確勝過含混
簡潔勝過復雜
復雜好過混亂
平坦強于嵌套
留白好過抱團
通俗易懂有偉大的價值
沒有什么能特殊到值得犧牲這些原則
盡管現(xiàn)實經(jīng)常玷污這些純凈
錯誤永不可輕易原諒
除非坦誠相對
面對模棱兩可痴奏,拒絕猜測的誘惑
那兒應該有一條,也只有一條明確的道路通向彼岸
盡管一開始那條路可能不是那樣明顯厌秒,除非你是Dutch
現(xiàn)在行動好過從不行動
盡管不行動經(jīng)常比魯莽行動要好
如果實現(xiàn)難以解釋读拆,那是一個壞主意
如果實現(xiàn)容易解釋,那可能是個好主意
命名空間是一個偉大的注意--我們應該好好利用
- Dutch現(xiàn)在不知道怎樣翻譯鸵闪,翻譯成荷蘭人不對檐晕,或許是說荷蘭人祖先是北歐海盜,曾橫行海上蚌讼,不缺判別方向的直覺辟灰,但是找不到中文中比較好的說法;
- Spares和dense應該是編程中的松耦合篡石,和緊耦合的概念芥喇,這里翻譯得更情緒一點;
- 這些句子的后半段感覺還是太寫實凰萨,如果完全意譯就不好理解继控,直譯則覺得作為詩的韻味直線下降。