Python之禅( The Zen of Python )

The Zen of Python, by Tim Peters

在控制台上输入

1.Python

2.import this

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之父Guido。

现在开始做比什么也不做强。

虽然什么也不做永远比不做更好。

如果实现方式很难去解释,那这不是一个好的实现。

命名空间是一个超好的机制,我们需要更多的使用。

posted @ 2022-04-14 11:57  CheeseIce  阅读(177)  评论(0编辑  收藏  举报