都知道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之禪
美麗勝過丑陋
明確勝過含混
簡潔勝過復雜
復雜好過混亂
平坦強于嵌套
留白好過抱團
通俗易懂有偉大的價值
沒有什么能特殊到值得犧牲這些原則
盡管現實經常玷污這些純凈
錯誤永不可輕易原諒
除非坦誠相對
面對模棱兩可,拒絕猜測的誘惑
那兒應該有一條,也只有一條明確的道路通向彼岸
盡管一開始那條路可能不是那樣明顯,除非你是Dutch
現在行動好過從不行動
盡管不行動經常比魯莽行動要好
如果實現難以解釋,那是一個壞主意
如果實現容易解釋,那可能是個好主意
命名空間是一個偉大的注意--我們應該好好利用
- Dutch現在不知道怎樣翻譯,翻譯成荷蘭人不對,或許是說荷蘭人祖先是北歐海盜,曾橫行海上,不缺判別方向的直覺,但是找不到中文中比較好的說法;
- Spares和dense應該是編程中的松耦合,和緊耦合的概念,這里翻譯得更情緒一點;
- 這些句子的后半段感覺還是太寫實,如果完全意譯就不好理解,直譯則覺得作為詩的韻味直線下降。