The Zen of Python——Python之禅

作者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! 命名空间是一个伟大的灵光,让我们多做几次

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容