import this

 The Zen of Python, by Tim Peters
# python的设计哲学, 作者:Tim Peters Beautiful is better than ugly.
# 优雅胜于丑陋(Python 以编写优美的代码为目标) 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.
# 错误不可置之不理,除非你确定需要这样做(精准地捕获异常,不写 except:pass 风格的代码) 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.
# 虽然这种方式开始时并不容易,除非你是 Python之父(这里的 Dutch 是指 Guido ) 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哲学的更多相关文章

  1. 用 ElementTree 在 Python 中解析 XML

    用 ElementTree 在 Python 中解析 XML 原文: http://eli.thegreenplace.net/2012/03/15/processing-xml-in-python- ...

  2. 给深度学习入门者的Python快速教程 - 基础篇

    实在搞不定博客园的排版,排版更佳的版本在: https://zhuanlan.zhihu.com/p/24162430 Life is short, you need Python 人生苦短,我用Py ...

  3. python ConfigParser、shutil、subprocess、ElementTree模块简解

    ConfigParser 模块 一.ConfigParser简介ConfigParser 是用来读取配置文件的包.配置文件的格式如下:中括号“[ ]”内包含的为section.section 下面为类 ...

  4. Python应用与实践【转】

    转自:http://www.cnblogs.com/skynet/archive/2013/05/06/3063245.html 目录 1.      Python是什么? 1.1.      Pyt ...

  5. Python面试题汇总

    原文:http://blog.csdn.net/jerry_1126/article/details/44023949 拿网络上关于Python的面试题汇总了,给出了自认为合理的答案,有些题目不错,可 ...

  6. 1-了解Python

    为什么使用python: 软件质量: 可读写.一致性.软件质量 支持软件开发的高级重用机制 提供开发者的效率: 代码只有java或C++的1/5~1/3 无须编译链接,提高了程序原的效率 程序的可移植 ...

  7. python高级编程(第12章:优化学习)1

    # -*- coding: utf-8 -*-# python:2.x__author__ = 'Administrator'#由于5,6,7,8,9,10,11主要是在包,测试之类的学习所以这边就不 ...

  8. Python 一些有趣的技巧哦!

    #Python 技巧命令 python 如一股清流,可以说屌到飞起,下面咱就来看看一些屌的东西 ### python2 最简单的web服务 ` python -m SimpleHTTPServer 8 ...

  9. Python进阶 - 对象,名字以及绑定

    Python进阶 - 对象,名字以及绑定 1.一切皆对象 Python哲学: Python中一切皆对象 1.1 数据模型-对象,值以及类型 对象是Python对数据的抽象.Python程序中所有的数据 ...

随机推荐

  1. Dubbo源码分析(3):ExtensionFactory

    通过ExtensionFactory的getExtension方法获取目标对象.ExtensionFactory实现有两个,一个基于SPI的,一个Spring的ApplicationContext的. ...

  2. java利用反射动态获取实体类的属性值

    直接贴代码吧,有需要的话,可以根据自己的需要修改部分代码: public BigDecimal getByAttributeName(ThmdGwqriR thmdGwqriR, String att ...

  3. [TypeScript] Modifier

    TypeScript 2.8 adds the ability for a mapped type to either add or remove a particular modifier. Spe ...

  4. SIGAI机器学习第十九集 随机森林

    讲授集成学习的概念,Bootstrap抽样,Bagging算法,随机森林的原理,训练算法,包外误差,计算变量的重要性,实际应用 大纲: 集成学习简介 Boostrap抽样 Bagging算法 随机森林 ...

  5. Java【基础学习】向下转型和上转型例子

    Java小白应付期末考试QWQ class Animal{ public void move() { System.); } } class Dog extends Animal{ public vo ...

  6. 历史相关API

    一.history对象 ①history.back()移动到上一个访问页面,等同于浏览器的后退键. ②history.forward()动到下一个访问页面,等同于浏览器的前进键. ③history.g ...

  7. leetcode解题报告(29):Student Attendance Record I

    描述 You are given a string representing an attendance record for a student. The record only contains ...

  8. Processing 2.1.1 无法使用video和movie问题解决方案

    升级到2.1.1后,尝试着运行了一下sample中的video和movie,结果都报错,上网搜了一下,找到解决方法. 1. 首先来看movie的错误,如下: JNA: Callback org.gst ...

  9. 力扣50题 Pow(x,n)

    本题是力扣网第50题. 实现 pow(x, n) ,即计算 x 的 n 次幂函数. 采用递归和非递归思路python实现. class Solution: #递归思路 def myPow_recurs ...

  10. leetcode 63 简单题

    题目很水... 直接放代码了 int uniquePathsWithObstacles(int** obstacleGrid, int obstacleGridRowSize, int obstacl ...