python之禅 the zen of python
>>> 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 以编写优美的代码为目标) 明了胜于晦涩(优美的代码应当是明了的,命名规范,风格相似) 简洁胜于复杂(优美的代码应当是简洁的,不要有复杂的内部实现) 复杂胜于凌乱(如果复杂不可避免,那代码间也不能有难懂的关系,要保持接口简洁) 扁平胜于嵌套(优美的代码应当是扁平的,不能有太多的嵌套) 间隔胜于紧凑(优美的代码有适当的间隔,不要奢望一行代码解决问题) 可读性很重要(优美的代码是可读的) 即便假借特例的实用性之名,也不可违背这些规则(这些规则至高无上) 不要包容所有错误,除非你确定需要这样做(精准地捕获异常,不写 except:pass 风格的代码) 当存在多种可能,不要尝试去猜测 而是尽量找一种,最好是唯一一种明显的解决方案(如果不确定,就用穷举法) 虽然这并不容易,因为你不是 Python 之父(这里的 Dutch 是指 Guido ) 做也许好过不做,但不假思索就动手还不如不做(动手之前要细思量) 如果你无法向人描述你的方案,那肯定不是一个好方案;反之亦然(方案测评标准) 命名空间是一种绝妙的理念,我们应当多加利用(倡导与号召)
python之禅 the zen of python的更多相关文章
- Python的设计哲学--zen of Python
Python的设计哲学--zen of Python Beautiful is better than ugly. 优美胜于丑陋 Explicit is better than ...
- Python import this : The Zen of Python
>>> import thisThe Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is b ...
- Python之禅+八荣八耻
Python之禅 (The Zen of Python):是Python语言的指导原则,可以在Python命令行输入import this显示. import this >>> Th ...
- Go for Pythonistas Go and the Zen of Python 禅
Go for Pythonistas https://talks.golang.org/2013/go4python.slide#1 Things I don't like about Python ...
- funny_python 00 The Zen of Python
# 打算每天多动的时候尽量搜索一些和coding相关的funny stuff Day 00 - PEP 20 The Zen of Python 在shell里面输入python -m this 回车 ...
- 趣闻|Python之禅(The Zen of Python)
在Python解释器中输入“import this”会发生什么?如果你不知道这个彩蛋,推荐继续阅读这篇文章. 2001年秋,Foretec(一家会议组织公司)正在准备召开第十届Internationa ...
- python 之禅
想要真正深入了解一门语言,需要用心去感受.下面是python之禅,python的设计哲学,对于编程很有指导意义.(翻译部分摘自网络,同时自己有一些更改) >>> import thi ...
- Python的禅,“提姆彼得斯”说的非常有道理道出了这门编程语言的真谛!
The Zen of Python, by Tim Peters Beautiful is better than ugly.Explicit is better than implicit.Simp ...
- Python之禅及释义
在python shell中敲 import this会触发一个彩蛋,神奇的打印下面一段话: The Zen of Python, 即python之禅, 1999年Tim Peters大牛总结的&qu ...
随机推荐
- linux 小技巧(磁盘空间搜索)
这里记录一些linux 管理中可能会用到的又容易忘的一些小技巧. linux磁盘写入失败,提示磁盘空间不足.一般都会用df -h 或者df -i看是不是磁盘空间不足或者是inode空间不足.发生这种情 ...
- [leetcode-495-Teemo Attacking]
In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned ...
- 【LeetCode】219. Contains Duplicate II
题目: Given an array of integers and an integer k, find out whether there are two distinct indices i a ...
- H5本地储存Web Storage
一.本地存储由来的背景 由于HTML4时代Cookie的大小.格式.存储数据格式等限制,网站应用如果想在浏览器端存储用户的部分信息,那么只能借助于Cookie.但是Cookie的这些限制,也就导致了C ...
- VB6之多维数组中元素在内存中的排列情况
Private Declare Sub RtlMoveMemory Lib "kernel32" (Destination As Any, Source As Any, ByVal ...
- Codeforces Round #418 (Div. 2).C two points
C. An impassioned circulation of affection time limit per test 2 seconds memory limit per test 256 m ...
- POWERSHELL将域中的计算机移动到指定OU
POWERSHELL处理域中计算机的过程 由于集团公司规模较大,存在几个分公司并处在不同地理位置.采用域集中管理,各分公司都有自己的域控制器,分别负责各分公司的DNS解析,DHCP地址分配,及客户端登 ...
- Windows Redis默认配置文件,Redis配置不生效解决方案
Windows Redis默认配置文件,Redis配置不生效解决方案, Windows Redis自启动配置不生效解决方案,Windows Redis增加自动启动服务 >>>> ...
- 深入浅析JavaScript中的constructor
constructor 属性返回对创建此对象的数组函数的引用.本文给大家介绍JavaScript中的constructor ,需要的朋友参考下吧 定义和用法 constructor 属性返回对创建此对 ...
- 如何在python脚本里面连续执行adb shell后面的各种命令
如何在python脚本里面连续执行adb shell后面的各种命令 adb shell "cd /data/local && mkdir tmp" adb shel ...