查看原文
其他

Python之禅 最新翻译 蟒之禅

carry麦 码农真经 2023-12-25

我们在 Python 交互式解释器中输入 import this,就可以看到 Python 之禅的内容。

Python之禅

Python之禅 最早由 Tim Peters 在Python邮件列表中发表,它包含了影响Python编程语言设计的19条软件编写原则。

今天我试着翻译了一下,相对简洁,有利于记忆,希望能帮助到大家。

常规翻译

以下是Python之禅的中文翻译:

Zen of 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.应该有一种,而且不如说唯一一种,明显的解决方案。Although that way may not be obvious at first unless you're Dutch.尽管一开始并不明显,毕竟你不是那个荷兰人[Python 之父 Guido van Rossum]。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!命名空间真是一个顶呱呱的绝妙主意,让我们多做一些有关它的事情。

我的翻译

The Zen of 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.取法一,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!定名属。

往期推荐

欢迎关注我的公众号“码中人”,原创技术文章第一时间推送。


继续滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存