《Python之禅》的个人思考与翻译

我们学习了解一个编程语言之始,往往是用其去编写一个面世的程序。而Python在在她的“import this”中书写了20条Python哲学。

python -c "import this"

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!

美丽胜于丑陋
明晰强过隐晦
大巧而不工,重剑而无锋
扁平优于嵌套
稀疏胜过密集
可读重者恒重
特例也不足以违背秩序
尽管实践胜于纯粹
谬误理应遏止
除非我们保持沉默
直面分歧
御臆想之诱
求索之尽必是光明之途
呵,
此路难有坦途
除非你是那个荷兰人1
今朝有为胜过无为
即使,道常无为而无不为
道非可道,非上道
另外
命名空间是个很棒的想法

从Python之道中,我们可以发现:python中认定一个好的代码是无为的,是大巧不工的,是符合道家朴素唯物观的;随后指出在程序设计无坦途,必然会四处碰壁,但应对挫折与分歧时,要采取行动,有为胜于无为,可以解释清楚的决策才是好的决策而非道可道非常道,这里又有歧与道家思想。这也或许是Python哲学上的“分而治之”。


  1. “那个荷兰人”指的是Python之父——Guido van Rossum ↩︎

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ultimo2023

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值