Thursday, August 6, 2009

我翻译的 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 之禅
Tim Peters

美观胜过丑陋。
明确胜过隐晦。
简单胜过复杂。
平铺胜过嵌套。
错落有致胜过密密麻麻。
可读性很重要。
不要因为特例就违背原则。
即便实用比纯粹更重要。
错误从不该静静的失败。
除非明确让它沉默。
对待模棱两可,忍住 -- 不要去猜测。
应该有一个 -- 最好只有一个 -- 明确的方式来解决。
答案不会一目了然,除非你是荷兰人。
现在就做胜过永远不做。
虽然有时永远不做胜过“马上”去做。
如果实现难于阐述,它是一个坏主意。
如果实现能轻松讲清楚,它可能是个好方法。
命名空间是个好主意 -- 我们还能做更多!

No comments:

Post a Comment