SlideShare a Scribd company logo
SIMPLE IS
BETTER THAN COMPLEX
@cocodrips
知らない言語を初めて学ぶ時、
まず何をしますか?
まずそのプログラミング言語の
言語思想を学ぶ
Perl
「There’s More Than One Way To Do It.」
use English;
if ($INPUT_LINE_NUMBER >= 1 and
$INPUT_LINE_NUMBER <= 3 or $ARG =~ m/match/) {
print $ARG;
}
if (1..3 or /match/) { print }
print if 1..3 or /match/
まつもとゆきひろさん(Ruby)
「気分よく書けるのが1番良い」
The Zen of Python
Simple is better than complex. ~私がPythonを愛する理由~
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.
if i>0: return sqrt(i)
elif i==0: return 0
else: return 1j * sqrt(-i)
if i>0: return sqrt(i)
elif i==0: return 0
else: return 1j * sqrt(-i)
if i > 0:
return sqrt(i)
elif i == 0:
return 0
else:
return 1j * sqrt(-i)
Readability counts.
Special cases aren't special enough to
break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
try:
import this
except ImportError:
pass
!
try:
import this
except ImportError:
print('this is not available')
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.
with open('will_be_closed.txt', 'w') as f:
f.write('the sum of two primes > 2 is an even number')
raise AssertionError('this sentence is false')
f = open('stay_open.txt', 'w')
f.write('every even number > 2 is the sum of two primes')
assert not 'this sentence is false'
f.close()
Never:
Now:
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!
from module import *
import module as mo
おすすめの本
言語設計者たちが考えること
課題
import thisをして、dir(this)をしてみましょう。
thisの中にあるオブジェクトを用いて、import thisした
時に出てくる文章を作ってみましょう。
The Zen of Python
• 我々は「Python」に何を求めているのか? - gumi Engineer’s
Blog - http://d.hatena.ne.jp/gumilab/20120229/1330479257
!
• プログラマが持つべき心構え (The Zen of Python) - Qiita -
http://qiita.com/IshitaTakeshi/items/
e4145921c8dbf7ba57ef”
!
• There's more than one way to do it - Wikipedia, the free
encyclopedia - http://en.m.wikipedia.org/wiki/
There's_more_than_one_way_to_do_it

More Related Content

Similar to Simple is better than complex. ~私がPythonを愛する理由~ (9)

PPTX
Philosophy of python
Namita Nair
 
PDF
Zen of Python
Oded Rotter
 
PDF
Python @NCKU CSIE
Chih-Hsuan Kuo
 
PDF
Zen and the Art of Python
Clayton Parker
 
KEY
Code Fast, die() Early, Throw Structured Exceptions
John Anderson
 
PDF
Brogramming - Python, Bash for Data Processing, and Git
Ron Reiter
 
PDF
Ruby Gotchas
Dave Aronson
 
PDF
A Whirlwind Tour of Perl
dtreder
 
PDF
Skiena algorithm 2007 lecture01 introduction to algorithms
zukun
 
Philosophy of python
Namita Nair
 
Zen of Python
Oded Rotter
 
Python @NCKU CSIE
Chih-Hsuan Kuo
 
Zen and the Art of Python
Clayton Parker
 
Code Fast, die() Early, Throw Structured Exceptions
John Anderson
 
Brogramming - Python, Bash for Data Processing, and Git
Ron Reiter
 
Ruby Gotchas
Dave Aronson
 
A Whirlwind Tour of Perl
dtreder
 
Skiena algorithm 2007 lecture01 introduction to algorithms
zukun
 

More from cocodrips (10)

PDF
Python仮想環境構築の基礎と ツールの比較
cocodrips
 
PDF
スマホでDeepLearning実践入門(α版)
cocodrips
 
PDF
チームメイトのためにdocstringを書こう! pyconjp2019
cocodrips
 
PDF
Docstringを書こう!
cocodrips
 
PDF
Python update in 2018 #ll2018jp
cocodrips
 
PPTX
C++と仲良くなるためのn問 ~ポインタ編~ #ladiescpp
cocodrips
 
PDF
ポインタ渡しと参照渡し
cocodrips
 
PDF
女性のためのC++コミュニティ Ladies++
cocodrips
 
PDF
強くなるためのプログラミング -プログラミングに関する様々なコンテストとそのはじめ方-#pyconjp
cocodrips
 
PDF
Pythonではじめる競技プログラミング
cocodrips
 
Python仮想環境構築の基礎と ツールの比較
cocodrips
 
スマホでDeepLearning実践入門(α版)
cocodrips
 
チームメイトのためにdocstringを書こう! pyconjp2019
cocodrips
 
Docstringを書こう!
cocodrips
 
Python update in 2018 #ll2018jp
cocodrips
 
C++と仲良くなるためのn問 ~ポインタ編~ #ladiescpp
cocodrips
 
ポインタ渡しと参照渡し
cocodrips
 
女性のためのC++コミュニティ Ladies++
cocodrips
 
強くなるためのプログラミング -プログラミングに関する様々なコンテストとそのはじめ方-#pyconjp
cocodrips
 
Pythonではじめる競技プログラミング
cocodrips
 
Ad

Recently uploaded (20)

PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Ad

Simple is better than complex. ~私がPythonを愛する理由~