The Zen of Python

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命令行运行 Import this就会显示上面的诗歌:

>>> 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!

中文翻译:

优美胜于丑陋

明了胜于晦涩

简单胜于复杂

复杂胜于杂乱

扁平胜于嵌套

间隔胜于紧凑

可读性很重要

特例不足以特殊到违背这些原则

不要忽视错误,除非程序需要这样做

面对模棱两可,拒绝猜测

解决问题最直接的方法应该有一种,最好只有一种

可能这种方法一开始不够直接,因为你不是范罗苏姆

做也许好过不做,但不想就做还不如不做

如果方案难以描述明白,那么一定是个糟糕的方案

如果容易描述,那么可能是个好方案

命名空间是一种绝妙的理念,多加利用

Zen of Python(Python的19条哲学)的更多相关文章

  1. 学习 Python 编程的 19 个资源 (转)

    学习 Python 编程的 19 个资源 2018-01-07 数据与算法之美 编译:wzhvictor,英文:codecondo segmentfault.com/a/119000000418731 ...

  2. 马哥教育python网络班19期 学习目标

    马哥教育python网络班19期 学习目标: (1)按群里的学习进度表,来自行学习,学完时间6个月. (2)学完后,薪资能达到20K+每月.

  3. #Python绘制 文本进度条,带刷新、时间暂缓的

    #Python绘制 文本进度条,带刷新.时间暂缓的 #文本进度条 import time as T st=T.perf_counter() print('-'*6,'执行开始','-'*6) maxx ...

  4. python --- Python中的callable 函数

    python --- Python中的callable 函数 转自: http://archive.cnblogs.com/a/1798319/ Python中的callable 函数 callabl ...

  5. Micro Python - Python for microcontrollers

    Micro Python - Python for microcontrollers MicroPython

  6. 19条MySQL优化准则

    1.EXPLAIN 做MySQL优化,我们要善用EXPLAIN查看SQL执行计划. 下面来个简单的示例,标注(1.2.3.4.5)我们要重点关注的数据: type列,连接类型.一个好的SQL语句至少要 ...

  7. 从Scratch到Python——python turtle 一种比pygame更加简洁的实现

    从Scratch到Python--python turtle 一种比pygame更加简洁的实现 现在很多学校都开设了Scratch课程,学生可以利用Scratch创作丰富的作品,然而Scratch之后 ...

  8. 从Scratch到Python——Python生成二维码

    # Python利用pyqrcode模块生成二维码 import pyqrcode import sys number = pyqrcode.create('从Scratch到Python--Pyth ...

  9. 巧用这19条MySQL优化,效率至少提高3倍

    阅读本文大概需要 3.8 分钟. 作者丨喜欢拿铁的人 https://zhuanlan.zhihu.com/p/49888088 本文我们来谈谈项目中常用的MySQL优化方法,共19条,具体如下: 1 ...

随机推荐

  1. while循环输出的表格

    方法一: <?php echo '<table border="1" width="800" align="center"> ...

  2. LA 5010 Go Deeper 2-SAT 二分

    题意: 有\(n\)个布尔变量\(x_i\),有一个递归函数.如果满足条件\(x[a[dep]] + x[b[dep]] \neq c[dep]\),那么就再往深递归一层. 问最多能递归多少层. 分析 ...

  3. loj2027 「SHOI2016」黑暗前的幻想乡

    矩阵树定理+模意义下整数高斯消元 #include <algorithm> #include <iostream> #include <cstring> #incl ...

  4. 栈的push、pop序列 【微软面试100题 第二十九题】

    题目要求: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1.2.3.4.5是某栈的压栈序列,序列4.5.3.2.1是该压栈 ...

  5. python学习-- 两种方式查看自己的Django版本

    [第一种方式] Windows系统下 按住Windows按键 + R 进入搜索:搜索CMD进入控制台:输入Python进入Python解释器 Linux系统下 直接使用终端调用Python解释器 接下 ...

  6. Educational Codeforces Round 37 (Rated for Div. 2)

    我的代码应该不会被hack,立个flag A. Water The Garden time limit per test 1 second memory limit per test 256 mega ...

  7. rest-framwork官方文档教程(一)

    该项目是按照官网quickstart进行的,具体也可查看rest-framework官网: https://www.django-rest-framework.org/tutorial/quickst ...

  8. NOJ——1665夜神的思考(YY+组合问题+分类讨论)

    [1665] 夜神的思考 时间限制: 1000 ms 内存限制: 65535 K 问题描述 最近夜神对二进制很感兴趣,于是他每次看到一串只包含1和0的字符串的时候就会想,这串字符串有多少子串是含有k个 ...

  9. [转] Makefile 基础 (4) —— Makefile 书写命令

    该篇文章为转载,是对原作者系列文章的总汇加上标注. 支持原创,请移步陈浩大神博客:(最原始版本) http://blog.csdn.net/haoel/article/details/2886 我转自 ...

  10. 代码动态改变 NGUI UILabel 的字体

    有一次因为 ttf 分成简体和繁体两个..所以就需要动态改变NGUI 中 UILabel 的字体,但是不知道 UILabel 保存字体的字段是哪个 网上搜到..在这里记录一下 using UnityE ...