ゆとり大学院生の日常~なんかいいことないかな~

留年と隣り合わせの情報系大学院生の日常。

pythonの組み込みで存在するpythonでコーディングする上での哲学~The Zen of Python~

こんにちは。留年予備軍です。

今回はpythonに組み込まれているThe Zen of Pythonをご紹介したいと思います。

The Zen of Pythonとは

The Zen of Pythonとはpythonの対話型インタープリタ

>>> 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という名前もコメディアンのモンティ・パイソンからきているくらいなので割とwitに富んだプログラミング言語であることは間違いなく僕はこの辺から一気にpythonを習得してみたくなりました。

まとめ

pythonはシンプルでおしゃれで可読性に優れていることは開発における理念だったりします。
こんなおしゃれな言語使ってみたいなとかいう動機で学び始める方におすすめです(笑)
ただCプログラマーだった人、特に理系の人なんかだと配列の計算でfor文をぶん回した経験があるはず(笑)
しかしながらpythonを含むインタープリタ言語(コンパイラで最適化しない言語)はそれをすると開発スピードがかなり遅くなったりします。 なのでpythonを基本から学んでぜひpythonらしさみたいなものが習得できたらpython本来の機能美に触れられてもっと楽しく開発できるのではないかと最近思っています。

長くなりましたがこんな感じでpythonを学ぶと面白いのでぜひ一緒に学んでいきましょうということで今回はこれで失礼します(笑)