
https://zhuanlan.zhihu.com/p/40950546
$ pythonPython 3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, 13:27:36) [GCC 11.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import thisThe Zen of Python, by Tim PetersBeautiful 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!>>> exit()
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.尽管这方案一开始并不直观(调侃Python之父Guido)。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!命名空间是超棒的设计,多多善用!
读音:chán(这里Zen/禅读chán,佛教禅宗;另外还有shàn,禅让,与此无关)
源自梵语「dhyāna」,本义:静思、静心观照、向内自省。 禅宗核心:放下繁杂执念,回归本质、求真、通透,不搞虚浮繁复的形式。 英文Zen就是日语「禅」的音译,Python用The Zen of Python,意思是:Python这套语言的内在修行、底层心性准则。
完全对标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. 做人:建立稳定的三观与处事标准。 待人、做事有一贯的准则,不双重标准,不随心情反复变卦。
代码:Now is better than never. Although never is often better than right now. 做人:想做的事不要一直拖延,但绝不头脑发热仓促决定。 躺平空想不如适度行动;冲动莽撞,不如暂缓观望。
代码:If hard to explain, bad idea; easy to explain, good idea. 做人:一段关系、一个选择,如果你说不清为什么坚持,大概率是执念、内耗; 若是逻辑清晰、心安理得,才是适合你的选择。
代码:Namespaces are one honking great idea 做人:分清自我与他人,守住自己的精神边界。 不随意介入别人的人生,也不让别人随意干涉你的生活,减少精神消耗。
Python之禅是写代码的克制与通透; 人生之禅是做人的清醒与松弛。 二者内核完全相通:去繁、求真、坦诚、务实、少内耗、守本心。