Python 的设计哲学是“优雅”、“明确”、“简单”。因此,Perl 语言中“总是有多种方法来做同一件事”的理念在 Python 开发者中通常是难以忍受的。Python 开发者的哲学是“用一种方法,最好是只有一种方法来做一件事”。在设计 Python 语言时,如果面临多种选择,Python 开发者一般会拒绝花俏的语法,而选择明确的没有或者很少有歧义的语法。由于这种设计观念的差异,Python 源代码通常被认为比 Perl 具备更好的可读性,并且能够支撑大规模的软件开发。这些准则被称为Python 格言。

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

原文链接:http://www.menglanglang.cn/blog-post/computer-technology/it-development/development-language/python/4749/

Python 格言(The Zen of Python)相关推荐

  1. 学了python可以干嘛-学 Python 都用来干嘛的?

    一.Python语言 /> Python是一种广泛使用的高级编程语言,属于通用型编程语言,是完全面向对象的语言.函数.模块.数字.字符串都是对象.经常被用于Web开发.GUI开发.操作系统.科学 ...

  2. 《The Zen of Python, Explained》Posted by Al Sweigart in python - 中译版

    对Python之禅的解释 由 Al Sweigart 发布 Tim Peters 所著的 Python之禅 是20条关于 Python 语言设计的指导.你的 Python 代码不必要一定遵循这些指导, ...

  3. python之父名言_人生苦短 Python 格言

    系统内显示 Python格言 方法 import this In [1]: import this The Zen of Python, by Tim Peters Beautiful is bett ...

  4. python zen_Python的宗旨(Zen of Python)

    我们在Python中导入this模块,会打印出一段字符串: import this 翻译对照如下: The Zen of Python, by Tim Peters Python的宗旨,Tim Pet ...

  5. PEP 20 -- The Zen of Python(Python之禅)

    也许大家都听说过"Python之禅",它是由Python的核心开发成员之一Tim Peter写,成为Python编程和设计的指导原则. 也许大家还知道在python解释器中输入im ...

  6. The Zen of Python, by Tim Peters

    刚开始用python的时候在书上看到了,今天忽然看到一位博友的博文,又找出来了,我一直把其中的一些思想放到我的其他语言中,算是盲目的膜拜与颤栗的摸索. The Zen of Python, by Ti ...

  7. The Zen of Python

    zen 即禅之意 可以在python的命名行交互模式下以下的语句就能看到: import this The Zen of Python, by Tim PetersBeautiful is bette ...

  8. zen of python什么意思_如何理解「The Zen of Python」?

    import this The Zen of Python, by Tim Peters Python之禅 ,by Tim Peters Beautiful is better than ugly. ...

  9. python的设计哲学是什么意思_Python彩蛋:哲学理念及设计思想(The Zen of Python, by Tim Peters)...

    为了更好的了解Python哲学理念及设计思想,可以在任何一个Python交互解释器中输入import this命令.就会出现Python的一个彩蛋,描述了一系列Python的设计原则,阅读一下这些文字 ...

最新文章

  1. 黄仁勋入选《时代》杂志2021最具影响力100人,库克、马斯克也上榜
  2. HDLBits 系列(11)All about Adder
  3. Python编辑器与集成开发环境(IDE)选择
  4. python如何读取mat文件可视化_python Matplotlib数据可视化(1):简单入门
  5. 简述网卡的作用和工作原理_凯狄简述抽芯铆钉的作用原理
  6. python urllib.request 爬虫 数据处理-使用Python3.5写简单网络爬虫
  7. Maven修改默认仓库为阿里云仓库
  8. 常用控件 winform
  9. Cppcheck 1 54 C/C++静态代码分析工具
  10. 如何使用 Visual C# 加密和解密文件
  11. linux中文显示和输入
  12. Mac OS X10.11下CocoaPods的安装过程
  13. PIN/PAD Design in SoC - 2 (待续)
  14. 破解 京东登录滑块验证
  15. 微信小程序后台服务器怎么配置,如何在微信小程序后台设置服务类目
  16. 如何利用jqGrid表格方法重新设置caption属性值
  17. python中计算ln和lg的方法
  18. Adyen海外支付 - 直付
  19. 第十六周学习周报20181224-20181230
  20. DOTCPP:有关1148心得

热门文章

  1. springboot中使用模板⽅法设计模式-设计模块(六)
  2. React之PixiJS之渲染复杂SVG
  3. 【python】 安装浏览器驱动器
  4. java.lang.NoClassDefFoundError: net/sf/ehcache/CacheManager
  5. APP性能测试之启动耗时
  6. 城市公园智能化中的5G千兆网关应用
  7. 姜思达和机器人_杜江 肉眼可见的紧张:一身正气唱情歌,恭喜霍思燕喜提机器人老公!...
  8. 虚拟服务器zend optimizer,HostEase主机如何开启zend optimizer程序
  9. Visdom 解决OSError: [Errno 98] Address already in use
  10. wp load.php下载,wordpress网站打开首页出现下载页面解决方法