静かなる名辞

pythonとプログラミングのこと


【python】The Anti-Zen of Pythonの和訳

 The Anti-Zen of Pythonというネタがある。そもそも「The Zen of Python」というpython使いの過半数が知っているネタがあるのだが、それに反対する文書である。

Welcome to that’s documentation! — that 1.0.7 documentation

 the zen of pythonはデフォルトでインストールされていて、「import this」で表示される。一方、「The Anti-Zen of Python」は当然デフォルトでは入っていないので、「pip install that」で入れてやる必要がある(import thatで表示される)。でもせっかく入れてやっても英語なので、日本人にとっては読むのが面倒くさい。

 ということで、和訳してみた。

原文

The Anti-Zen of Python, by Daniel Greenfeld

Ugly is better than beautiful.
Implicit is better than explicit.
Complicated is better than complex.
Complex is better than simple.
Nested is better than flat.
Dense is better than sparse.
Line code counts.
Special cases are special enough to break the rules.
Although purity beats practicality.
Errors should always pass silently.
Spelchek iz fur loosers.
In the face of ambiguity, one guess is as good as another.
There should be many ways to do it.
Because only a tiny minority of us are Dutch.
Get things running, then fix them later.
If the implementation is hard to explain, it's enterprisey.
If the implementation is easy to explain, it won't take enough time to do.
Namespaces are too hard, just use "from module import *"!

和訳

「反Zen of Python」 Daniel Greenfeld作

醜さは美しさより良い。
明示的より暗示的な方が良い。
滅茶苦茶なのは単に複雑なことより良いことだ。
複雑もシンプルよりは良い。
よりたくさんネストするべきだ。
スカスカよりぎっちり詰め込んだ方が良い。
行数が重要だ。*1
Special casesはルールを破れるってだけで素晴らしい!*2
だけど、純粋性は実用性を打ち負す。
エラーは常に黙ってパスされるべき。
講分チェッ力とk負けグミのおm茶だよね~*3
曖昧さに直面したとき、適当に推測することは他の解決法と同じくらい良い。
あることをするのに、何通りものやり方があった方が良い。
なぜなら、オランダ人はプログラマ人口のほんのわずかな比率しか占めていないのだから。*4
とりあえず実行し、それから修正しろ。
もし実装を説明しづらかったら、商用ソフトみたいだね!*5
もし実装を簡単に説明できるなら、そんなんじゃ商品になんないよ~*6
名前空間とか難しすぎるから、"from module import *"使おうぜ!

 ひどい内容。しかも(私の英語力の問題もあるが)、訳しづらかったり意味がよくわからない部分がたくさんある。大量の注釈がそれを物語っている。

実装を見たい方へ

 こんなライブラリなので、当然というか、コードも酷く、醜く、下らない(褒め言葉)。

 githubにすべて上がっているので、興味のある方は見てみるのも良いかもしれない。

github.com

 ぶっちゃけ確実に時間の無駄になるが。

*1:原文は「Line code counts.」だが、Line codeだと伝送路になってしまう。lines of code:行数と解釈して訳したが、間違ってるかもしれない。countsの複数の意味(重要である、数える)をかけた何かの洒落なのかもしれない。英語が得意な人に教えて欲しい

*2:ここすき

*3:原文は「Spelchek iz fur loosers.」、たぶん「Spell Check is for losers.」→「スペルチェックは負け組のためのもの」だと思うが、保証はしない。対応する原文がないが、何か元ネタがあるのだろうか?

*4:オリジナルのZen of Pythonの「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.(そのやり方は、あなたがオランダ人でない限り一見しただけでは理解できないかもしれないが、そうだとしてもだ)」と対応。Dutchは言うまでもなくpython言語を作ったGuido van Rossumのことである

*5:「enterprisey」はそういう意味らしい。https://en.wiktionary.org/wiki/enterpriseyに書いてある。初めて知った

*6:原文は「If the implementation is easy to explain, it won't take enough time to do.」。よくわからないので、上との対応を考えてこう訳した。合ってるかもしれないし無理があるかもしれない。自信がない