- Python数据分析入门:从数据获取到可视化
- 沈祥壮
- 397字
- 2020-08-28 01:45:51
1.3 The Zen of Python
开始正式学习本书的最后一个准备工作,便是对这门编程语言的艺术有一个了解。打开IPython,输入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之禅 优美胜于丑陋 明确胜于隐晦 简单胜于复杂 复杂胜于凌乱 扁平胜于嵌套 稀疏胜于紧凑 可读性至关重要 即便特例,也需服从以上规则 除非刻意追求,错误不应跳过 面对歧义条件,拒绝尝试猜测 解决问题的最优方法应该有且只有一个 尽管这一方法并非显而易见(除非你是Python之父) 动手胜于空想 空想胜于不想 难以解释的实现方案,不是好方案 易于解释的实现方案,才是好方案 命名空间是个绝妙的理念,多多益善!