Python:import thisでPython公案を表示

スポンサーリンク

import thisでPython公案を表示

REPL(対話型インタプリタ)でimport thisと入力して実行すると、Python哲学を簡潔に表現した自由詩を表示することができます。

>>> import this
The Zen of Python, by Tim Peters

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!

日本語訳

Python公案(Tim Peters作)

酷いより美しい方がいい。
暗黙より明示の方がいい。
複雑より単純の方がいい。
極端な複雑よりただの複雑の方がいい。
入れ子よりフラットの方がいい。
密よりも疎の方がいい。
読みやすさは大切だ。
特殊条件だからといって原則を破っていいわけではないが、
実用性は純粋性に勝る。
わざと黙らされている場合を除き、
無言でエラーを次に渡してはならない。
曖昧なものが出てきたときに推測に頼るな。
仕事をするための当然の方法はひとつある。むしろ、ひとつだけだと言いたいところだ。
ただし、オランダ人でなければ、最初からその方法を当然とは思わないかもしれないが。
今するのはしないままよりもいい。
もっとも、しないままの方が慌てて今すぐよりもいいことが多い。
実装を説明するのが難しいなら、それは悪いアイデアだ。
実装を説明するのが簡単なら、それはいいアイデアかもしれない。
名前空間はすばらしいアイデアのひとつだ。もっとアイデアを出そう!