The Zen of Python, by Tim Peters

深蓝 posted @ 2011年10月17日 18:48 in python with tags zen , 5473 阅读

 

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!
 
 
Avatar_small
Wayne 说:
2011年10月19日 17:59

Beauty is subjective.
Explicit is recommended, but not required.
Simple is good, but complex can be good too.
And although complicated is bad,
Verbose and complicated is worse.
Brief is better than long-winded.
But readability counts.
So use whitespace to enhance readability.
Not because you're required to.
Practicality always beats purity.
In the face of ambiguity, do what I mean.
There's more than one way to do it.
Although that might not be obvious unless you're a Monk.
At your discretion is better than not at all.
Although your discretion should be used judiciously.
Just because the code looks clean doesn't mean it is good.
Just because the code looks messy doesn't mean it is bad.
Reuse via CPAN is one honking great idea -- let's do more of that!

---------Zen Of Perl

Avatar_small
深蓝 说:
2011年10月20日 14:49

@Wayne: Orz,这是您自个写的么?作为一个刚入门Python的人,Python的彩蛋实在让我惊喜

Avatar_small
Wayne 说:
2011年10月20日 21:35

@深蓝: 不是。是网上有人仿照 Zen Of Python 写的 Perl 版。从中可以看出 Perl 跟 Python 截然相反的一点。


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter