7.2 设计哲学:Python之禅

Python的设计哲学浓缩在“Python之禅”(The Zen of Python)中,通过在Python解释器中输入import this可以查看:

plaintext
复制代码
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.(可读性很重要)
...

这些原则指导了Python的每一个设计决策。Python社区将这些原则奉为圭臬,形成了独特的代码美学。