Let's feel about what "pythonic" is! ![](../../../images/smiles/icon_wink.gif)
>>> 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!
>>>
Translation from http://wiki.woodpecker.org.cn/moin/PythonZen:
Python 之禅:
优美胜过丑陋
明确胜过含蓄
简单胜过复杂
复杂胜过难懂
扁平胜过嵌套
稀疏胜过密集
易读亦有价
尽管实用会击败纯洁
特例也不能特殊到打破规则
除非明确地使其沉默
错误永远不应默默地溜掉
面对着不确定,要拒绝猜测的诱惑
应该有一个--宁肯只有一个--明显的实现方法
也许这个方法开始不是很明显,除非你是荷兰人
尽管不做通常好过立刻做
但现在做也要胜过不去做
如果实现很难解释,那它就是一个坏想法
如果实现容易解释,那它可能就是一个好想法
名字空间是一个响亮的出色想法--就让我们多用用它们
-- Tim Peters
-- 译:limodou
分享到:
相关推荐
14.6_None|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全解读
14.2_用字典映射代替switch_case语句|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原
14.11_Python_3.8_新增海象运算符|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生
14.13_Python_3.7_新增数据类dataclass装饰器|Pythonic与Python杂记|Python3.8入门
14.1_导言|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全解读
14.5_iterator与generator|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬
14.10_论编程能力|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全解读
14.9_装饰器的副作用|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全解读
14.12_f关键字做字符串拼接|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全解读
14.4_字典如何编写列表推导式|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全解读
14.7_对象存在并不一定是True|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原生爬虫实战完全
14.8___len__与__bool__内置方法|Pythonic与Python杂记|Python3.8入门_&_进阶_&_原
"cookiecutter-flask-pythonic:Flask的Pythonic入门样板" 这个标题表明,这是一个基于Cookiecutter工具的Flask项目模板,旨在为初学者提供一个遵循Python最佳实践(Pythonic)的Flask应用起点。Pythonic指的是遵循...
Pythonic 本项目是公众号:Python编程与实战 上有关项目代码 1、wei_bo:爬取微博评论,并作词云图,1.jpg 为背景图 运行 spider.py 文件即可 2、哪吒电影数据可视化项目 ne_zha,运行 spider.py 文件即可,生成对应...
1 Introduction 2 Patterns for Cleaner Python 3 Effective Functions 4 Classes & OOP 5 Common Data Structures in Python 6 Looping & Iteration ...8 Pythonic Productivity Techniques 9 Closing Thoughts
Matlab代码sqrt 八度Pythonic软件包 Pythonic是一个软件包,可为提供本地调用接口。 用法 使用pkg命令将此软件包安装在Octave中 pkg install ...
安装您可以从安装此软件包M-x package-install RET pythonic RET用法该库提供了在本地和远程主机(包括Docker容器和Vagrant虚拟机)上的不同平台上方便地运行python的功能。 要将pythonic与Docker结合使用,您需要...
Pythonic and Reusable Code,python代码的可重用,更Pythonic 的技巧,好的代码,书中有将近30多个例子,让你了解更Pythonic代码写法,让你更了解python语言
Python是一种解释型的、面向对象的、带有动态语义的高级程序设计语言。它是由荷兰人吉多·罗萨姆于1989年发布的,第一个公开发行版发行于1991年。Python注重解决问题的方法,而不是语法和结构。它被广泛应用于各个...
第14章 Pythonic与Python杂记.mp4