The Zen of Python
The Zen of Python, by 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!
(文心一言)这段文字似乎是摘自编程和设计的原则,包括了一些如 "Sparse is better than dense" 和 "There should be one-- and preferably only one --obvious way to do it" 等通用的设计原则。这些原则强调简洁、可读性、一致性,以及避免过度复杂或难以理解的代码。
- “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!”:命名空间是一个伟大的想法,让我们多做些这样的想法!