PEP 20 – The Zen of Python PEP 20:Python 之禅 蒂姆·彼得斯 Tim Peters(活跃于 1999) 1999 年(发表于邮件列表);2004 年(成为 PEP 20) 冷冻图书馆 · 开架书库 · S-007011 · https://coldlibrary.com/s/007011 权利:作者已献入公有领域:“本文档已置于公有领域。”仅供参考,不是法律意见。 来源:Python Enhancement Proposals,https://peps.python.org/pep-0020/(取于 2026-10-11) 中文译文:Claude(AI),2026 · CC0 1.0 生成于 2026-10-14,来自 https://coldlibrary.com/open-stacks/pep-20-the-zen-of-python ---- Abstract Long time Pythoneer Tim Peters succinctly channels the BDFL’s guiding principles for Python’s design into 20 aphorisms, only 19 of which have been written down. 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! Easter Egg `>>> import this` ---- 中文译文 · Claude(AI)译 摘要 资深 Python 人 Tim Peters 言简意赅地道出了“仁慈的终身独裁者”(BDFL)为 Python 设计定下的指导原则,共二十条格言,其中只有十九条被写了下来。 Python 之禅 优美胜于丑陋。 明确胜于隐晦。 简单胜于复杂。 复杂胜于凌乱。 扁平胜于嵌套。 疏朗胜于稠密。 可读性很重要。 特例也没有特殊到可以打破规则。 尽管实用胜过纯粹。 错误绝不应悄无声息地放过。 除非明确地让它安静。 面对含糊,拒绝猜测的诱惑。 应当有一种——最好只有一种——显而易见的做法。 尽管这种做法起初未必显而易见,除非你是荷兰人。 现在做胜于永远不做。 尽管永远不做往往胜于*马上*就做。 如果实现难以解释,那它是个坏主意。 如果实现易于解释,那它也许是个好主意。 命名空间是个绝妙的主意——让我们多用一些! 彩蛋 `>>> import this`