Python 之禅是 Python 语言的设计哲学与所倡导的编程理念,Pythonic 则是指基于 Python 理念编写更加符合 Python 语法习惯(idiomatic Python)的代码,这也是本项目所追求的目标,所以以本篇做为开头。html
import this
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!
Python 之禅,by Tim Peterspython
优美胜于丑陋编程
明确胜于隐晦less
简单胜于复杂ide
复杂胜于凌乱post
扁平胜于嵌套ui
稀疏胜于紧凑this
可读性相当重要idea
即使特例,也需服从以上规则spa
除非刻意追求,错误不该跳过
面对歧义条件,拒绝尝试猜想
解决问题的最优方法应该有且只有一个
尽管这一方法并不是显而易见(除非你是Python之父)
动手胜于空想
空想胜于不想
难以解释的实现方案,不是好方案
易于解释的实现方案,才是好方案
命名空间是个绝妙的理念,多多益善!