3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

The Zen of Pythonについてまとめてみました。

The Zen of Python

import thisを実行します。

import this

英語の文書が表示されます。これは、Tim Peters氏によってまとめられた"The Zen of Python"です。
Zenは、日本語の「」に由来します。

出力結果
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!

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 oftern 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!4

複数の名前空間の使い分けは、とても優れたアイディアだ。他にもたくさんアイディアを使おう。

おわりに

ここまで読んでいただきありがとうございます!

参考文献

・新・明解Python入門 (新・明解シリーズ) 単行本 – 2019/5/23
柴田 望洋 (著)
p.22-23

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?