关于IT运维技术的
最佳实践博客网站

Python里隐藏的“禅”和 Python程序员的八荣八耻

转载这篇文章主要介绍了IT柏拉图翻译的python的lib目录下this.py文件中的一首诗,蕴含了Python程序设计中很多哲理性的规律,需要的朋友可以参考下

The Zen of Python, by Tim Peters
《Python 的禅》 by 提姆·彼特

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程序员的八荣八耻

以动手实践为荣 , 以只看不练为耻;

以打印日志为荣 , 以单步跟踪为耻;

以空格缩进为荣 , 以制表缩进为耻;

以单元测试为荣 , 以人工测试为耻;

以模块复用为荣 , 以复制粘贴为耻;

以多态应用为荣 , 以分支判断为耻;

Pythonic为荣 , 以冗余拖沓为耻;

以总结分享为荣 , 以跪求其解为耻;

赞(0)
未经允许不得转载:菜鸟HOW站长 » Python里隐藏的“禅”和 Python程序员的八荣八耻
分享到: 更多 (0)

留下你的脚印

  订阅  
关注动态