美文网首页
2019-06-06

2019-06-06

作者: 码书 | 来源:发表于2019-06-06 16:39 被阅读0次

The Zen of Python, by Tim Peters(Python之禅,蒂姆•彼得斯)

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.

所有错误都不应该被直接忽略,除非能够被精确的捕获之后。(其中一个典型的例子就是,不建议用Exception:pass来直接忽略所有异常。)

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.

当面对不明确的情况时,要拒绝去猜测的诱惑。应该有一种,最好是唯一一种,显而易见的解决方案。尽管起初,那种解决方案可能并不是那么显而易见,因为你不是Python 之父(这里的Dutch是指Python之父Guido Van Rossum,他是荷兰人。)

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!

命名空间是一个令人激动的伟大想法,让我们将它发扬光大。

相关文章

网友评论

      本文标题:2019-06-06

      本文链接:https://www.haomeiwen.com/subject/bcgexctx.html