Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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 /mat...
まつもとゆきひろさん(Ruby)
「気分よく書けるのが1番良い」
The Zen of Python
The Zen of Python, by Tim Peters
!
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than ...
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:...
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('th...
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 id...
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...
Simple is better than complex. ~私がPythonを愛する理由~
Upcoming SlideShare
Loading in …5
×

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

PyLadiesTokyo#1のときの資料

  • Login to see the comments

  • Be the first to like this

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

  1. 1. SIMPLE IS BETTER THAN COMPLEX
  2. 2. @cocodrips
  3. 3. 知らない言語を初めて学ぶ時、 まず何をしますか?
  4. 4. まずそのプログラミング言語の 言語思想を学ぶ
  5. 5. Perl 「There’s More Than One Way To Do It.」
  6. 6. 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/
  7. 7. まつもとゆきひろさん(Ruby) 「気分よく書けるのが1番良い」
  8. 8. The Zen of Python
  9. 9. 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!
  10. 10. Beautiful is better than ugly.
  11. 11. Explicit is better than implicit.
  12. 12. Simple is better than complex.
  13. 13. Complex is better than complicated.
  14. 14. Flat is better than nested.
  15. 15. Sparse is better than dense.
  16. 16. if i>0: return sqrt(i) elif i==0: return 0 else: return 1j * sqrt(-i)
  17. 17. 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)
  18. 18. Readability counts.
  19. 19. Special cases aren't special enough to break the rules.
  20. 20. Although practicality beats purity.
  21. 21. Errors should never pass silently. Unless explicitly silenced.
  22. 22. try: import this except ImportError: pass ! try: import this except ImportError: print('this is not available')
  23. 23. In the face of ambiguity, refuse the temptation to guess.
  24. 24. There should be one — and preferably only one — obvious way to do it.
  25. 25. Although that way may not be obvious at first unless you're Dutch.
  26. 26. Now is better than never.
  27. 27. 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:
  28. 28. Although never is often better than *right* now.
  29. 29. 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.
  30. 30. Namespaces are one honking great idea -- let's do more of those!
  31. 31. from module import *
  32. 32. import module as mo
  33. 33. おすすめの本 言語設計者たちが考えること
  34. 34. 課題 import thisをして、dir(this)をしてみましょう。 thisの中にあるオブジェクトを用いて、import thisした 時に出てくる文章を作ってみましょう。
  35. 35. The Zen of Python
  36. 36. • 我々は「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

×