95
世界一言語トークス by Python Yoshiori SHOJI 20091212日土曜日

世界一言語トークス by Python

Embed Size (px)

Citation preview

Page 1: 世界一言語トークス by Python

世界一言語トークスby PythonYoshiori SHOJI

2009年12月12日土曜日

Page 2: 世界一言語トークス by Python

世界一を目指す理由は何か2位ではだめなのか

2009年12月12日土曜日

Page 3: 世界一言語トークス by Python

2009年12月12日土曜日

Page 4: 世界一言語トークス by Python

私の事好き?

2009年12月12日土曜日

Page 5: 世界一言語トークス by Python

好きだよ

2009年12月12日土曜日

Page 6: 世界一言語トークス by Python

世界で一番好きでいてくれる?

2009年12月12日土曜日

Page 7: 世界一言語トークス by Python

世界一を目指す理由は何か

2位ではだめなのか

2009年12月12日土曜日

Page 8: 世界一言語トークス by Python

!?

2009年12月12日土曜日

Page 9: 世界一言語トークス by Python

2009年12月12日土曜日

Page 10: 世界一言語トークス by Python

name:$>

2009年12月12日土曜日

Page 11: 世界一言語トークス by Python

Yoshiori SHOJI

2009年12月12日土曜日

Page 12: 世界一言語トークス by Python

email:$>

2009年12月12日土曜日

Page 14: 世界一言語トークス by Python

site:$>

2009年12月12日土曜日

Page 15: 世界一言語トークス by Python

http://yoshiori.org/

2009年12月12日土曜日

Page 16: 世界一言語トークス by Python

company:$>

2009年12月12日土曜日

Page 17: 世界一言語トークス by Python

DWANGO Co.,Ltd.

2009年12月12日土曜日

Page 18: 世界一言語トークス by Python

2009年12月12日土曜日

Page 19: 世界一言語トークス by Python

yP t h o n2009年12月12日土曜日

Page 20: 世界一言語トークス by Python

yP t h o n2009年12月12日土曜日

Page 21: 世界一言語トークス by Python

yoshiori $

2009年12月12日土曜日

Page 22: 世界一言語トークス by Python

import this

2009年12月12日土曜日

Page 23: 世界一言語トークス by Python

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!

The Zenof

PythonPython のなかの’禅’

2009年12月12日土曜日

Page 24: 世界一言語トークス by Python

2009年12月12日土曜日

Page 25: 世界一言語トークス by Python

Pythonは汎用の高水準言語である。プログラマの生産性とコードの信頼性を重視して設計されており、核となるシンタックスおよびセマンティクスは必要最小限に抑えられている反面、利便性の高い大規模な標準ライブラリを備えている。

Unicodeによる文字列操作をサポートしており、日本語処理も標準で可能である。 多くのプラットフォームをサポートしており(動作するプラットフォーム)、また、豊富なドキュメント、豊富なライブラリがあることから、産業界でも利用が増えつつある。

2009年12月12日土曜日

Page 26: 世界一言語トークス by Python

Pythonは汎用の高水準言語である。プログラマの生産性とコードの信頼性を重視して設計されており、核となるシンタックスおよびセマンティクスは必要最小限に抑えられている反面、利便性の高い大規模な標準ライブラリを備えている。

Unicodeによる文字列操作をサポートしており、日本語処理も標準で可能である。 多くのプラットフォームをサポートしており(動作するプラットフォーム)、また、豊富なドキュメント、豊富なライブラリがあることから、産業界でも利用が増えつつある。

Wikipedia 見て!!http://ja.wikipedia.org/wiki/Python

2009年12月12日土曜日

Page 27: 世界一言語トークス by Python

簡単に言うと

2009年12月12日土曜日

Page 28: 世界一言語トークス by Python

Guido っていう人が作ったイカした言語

もちろんオブジェクト指向プログラミングだ!!

教育用として設計されたので言語仕様がシンプル!!

インデントでブロック構造あらわしてるぜ!!

電池が付属しています("Battery Included")

2009年12月12日土曜日

Page 29: 世界一言語トークス by Python

Ruby のように動的な型付けの

LL であり、C で簡単に拡張が書けるようになっていて、Scala や Groovy のように JVM

上でも動き、JavaScript のようなスコープと prototype 的な事も出来る言語

2009年12月12日土曜日

Page 30: 世界一言語トークス by Python

良くある

誤解

2009年12月12日土曜日

Page 31: 世界一言語トークス by Python

良くある

誤解

2009年12月12日土曜日

Page 32: 世界一言語トークス by Python

インデントがブロックってキモイ!!

2009年12月12日土曜日

Page 33: 世界一言語トークス by Python

えっ!?

2009年12月12日土曜日

Page 34: 世界一言語トークス by Python

ブロックでインデントしない方がキモイよね?

if(foo == bar){foo.hoge();} bar.hoge();foo.hoge(bar);bar.hoge(foo);if(hoge != foo) hoge.hoge(); foo.hoge();

2009年12月12日土曜日

Page 35: 世界一言語トークス by Python

実行時にワーニング出したり、スタイルチェックのために他のプログラム走らせるくらいなら、そもそも適切にインデントされてなければ動かなければいいよね

2009年12月12日土曜日

Page 36: 世界一言語トークス by Python

2009年12月12日土曜日

Page 37: 世界一言語トークス by Python

閉じタグが無いのがキモイ

2009年12月12日土曜日

Page 38: 世界一言語トークス by Python

えっ!?

2009年12月12日土曜日

Page 39: 世界一言語トークス by Python

書けばいいじゃん

end = None::def foo(): print ‘hoge’end

2009年12月12日土曜日

Page 40: 世界一言語トークス by Python

書けばいいじゃん

end = None::def foo(): print ‘hoge’end

2009年12月12日土曜日

Page 41: 世界一言語トークス by Python

書けばいいじゃん

end = None::def foo(): print ‘hoge’end

2009年12月12日土曜日

Page 42: 世界一言語トークス by Python

逆に考えるんだ!! Python は閉じタグを”強制”しない。書きたければ書けばいいし他の言語のように”強制”しないだけだと

2009年12月12日土曜日

Page 43: 世界一言語トークス by Python

2009年12月12日土曜日

Page 44: 世界一言語トークス by Python

関数呼び出しでカッコが必須なのがめんどくさい

2009年12月12日土曜日

Page 45: 世界一言語トークス by Python

えっ!?

2009年12月12日土曜日

Page 46: 世界一言語トークス by Python

def foo(): return 'hoge'

こういう関数があった場合

foo()

これは関数呼び出しになりますが、

foo

これは関数自体のオブジェクトを表わします

2009年12月12日土曜日

Page 47: 世界一言語トークス by Python

def foo(): return 'hoge'

def bar(func): print func()

bar(foo) # ‘hoge’

なので例えば関数の引数で関数を受けとった時にも、普通にカッコを付ければその関数を呼べます。

(call など特別な処理はいらない)

2009年12月12日土曜日

Page 48: 世界一言語トークス by Python

カッコを省略出来無いというよりは、カッコを付けた時と付けてない時で違う意味を持っているのです。(どちらが優れているとかでは無く)

2009年12月12日土曜日

Page 49: 世界一言語トークス by Python

2009年12月12日土曜日

Page 50: 世界一言語トークス by Python

インスタンスメソッドとか

self だらけでめんどくさい

2009年12月12日土曜日

Page 51: 世界一言語トークス by Python

えっ!?

2009年12月12日土曜日

Page 52: 世界一言語トークス by Python

class Hoge(object): pass

hoge = Hoge()

hoge.a = 10 // hoge に a を追加hoge.b = 'hoge'

print hoge.a // 10 と表示されるprint hoge.b // hoge と表示される

例えばオブジェクトの初期化を考えた時

2009年12月12日土曜日

Page 53: 世界一言語トークス by Python

def initialize(obj, a, b): obj.a = a obj.b = b

class Hoge(object): pass hoge = Hoge()initialize(hoge, 10, 'hoge') //関数print hoge.a // 10 と表示されるprint hoge.b // hoge と表示される

関数として切り出す

2009年12月12日土曜日

Page 54: 世界一言語トークス by Python

class Hoge(object): def initialize(obj, a, b): obj.a = a obj.b = b

hoge = Hoge()Hoge.initialize(hoge, 10, 'hoge') //クラス関数として呼びだし

print hoge.a // 10 と表示されるprint hoge.b // hoge と表示される

関数をクラスに持たせる

2009年12月12日土曜日

Page 55: 世界一言語トークス by Python

class Hoge(object): def initialize(obj, a, b): obj.a = a obj.b = b

hoge = Hoge()Hoge.initialize(hoge, 10, 'hoge') //クラス関数として呼びだし

print hoge.a // 10 と表示されるprint hoge.b // hoge と表示される

関数をクラスに持たせる

hoge.initialize(10,'hoge')// インスタンスメソッドとして呼びだし

2009年12月12日土曜日

Page 56: 世界一言語トークス by Python

class Hoge(object): def __init__(obj , a, b): obj.a = a obj.b = b

hoge = Hoge(10,'hoge') // 引数付きでコンストラクタ呼び出しprint hoge.a // 10 と表示されるprint hoge.b // hoge と表示される

コンストラクタとして呼びだす

2009年12月12日土曜日

Page 57: 世界一言語トークス by Python

class Hoge(object): def __init__(obj , a, b): obj.a = a obj.b = b

hoge = Hoge(10,'hoge') // 引数付きでコンストラクタ呼び出しprint hoge.a // 10 と表示されるprint hoge.b // hoge と表示される

コンストラクタとして呼びだす

selfself.a = aself.b = b

2009年12月12日土曜日

Page 58: 世界一言語トークス by Python

this などを明示的に書くか書かないかの違いだけど、書くのも悪くないでしょ?

2009年12月12日土曜日

Page 59: 世界一言語トークス by Python

2009年12月12日土曜日

Page 60: 世界一言語トークス by Python

PHP とか Perl みたいに気軽で安いレンタルサーバとか無いじゃん

2009年12月12日土曜日

Page 61: 世界一言語トークス by Python

えっ!?

2009年12月12日土曜日

Page 62: 世界一言語トークス by Python

あるよ!!

2009年12月12日土曜日

Page 63: 世界一言語トークス by Python

あるよ!!

2009年12月12日土曜日

Page 64: 世界一言語トークス by Python

基本タダなのに超スケールするらしいよ

2009年12月12日土曜日

Page 65: 世界一言語トークス by Python

2009年12月12日土曜日

Page 66: 世界一言語トークス by Python

hyP noイ カ ス 所

2009年12月12日土曜日

Page 67: 世界一言語トークス by Python

hyP noイ カ ス 所

2009年12月12日土曜日

Page 68: 世界一言語トークス by Python

予約語

2009年12月12日土曜日

Page 69: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

2009年12月12日土曜日

Page 70: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

2009年12月12日土曜日

Page 71: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

true

2009年12月12日土曜日

Page 72: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

true

false

2009年12月12日土曜日

Page 73: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

true

false

this

2009年12月12日土曜日

Page 74: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

true

false

this

super2009年12月12日土曜日

Page 75: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

true

false

this

super

None

True

False

self

super2009年12月12日土曜日

Page 76: 世界一言語トークス by Python

オブジェクトを表わすのに最低限必要な5つのもの

nil

true

false

this

super

None

True

False

self

super

予約語じゃないw

2009年12月12日土曜日

Page 77: 世界一言語トークス by Python

そんなALGOL系

オブジェクト指向言語

2009年12月12日土曜日

Page 78: 世界一言語トークス by Python

DRY

2009年12月12日土曜日

Page 79: 世界一言語トークス by Python

2009年12月12日土曜日

Page 80: 世界一言語トークス by Python

2009年12月12日土曜日

Page 81: 世界一言語トークス by Python

help(fizzbuzz)

2009年12月12日土曜日

Page 82: 世界一言語トークス by Python

help(fizzbuzz)

2009年12月12日土曜日

Page 83: 世界一言語トークス by Python

help(fizzbuzz)

テストコードです

2009年12月12日土曜日

Page 84: 世界一言語トークス by Python

ドキュメントが古くて実装の動きと違うとか

サンプル書いてテスト書いてとかの

2度手間が無い2009年12月12日土曜日

Page 85: 世界一言語トークス by Python

もちろん「電池が付属しています("Battery Included")」なのでこれも標準搭載

2009年12月12日土曜日

Page 86: 世界一言語トークス by Python

結論

2009年12月12日土曜日

Page 87: 世界一言語トークス by Python

世界一を目指す理由は何か2位ではだめなのか

2009年12月12日土曜日

Page 88: 世界一言語トークス by Python

ダメです

2009年12月12日土曜日

Page 89: 世界一言語トークス by Python

現状で

2009年12月12日土曜日

Page 90: 世界一言語トークス by Python

世界一である必要は無い

2009年12月12日土曜日

Page 91: 世界一言語トークス by Python

世界一を目指す

2009年12月12日土曜日

Page 92: 世界一言語トークス by Python

心意気

2009年12月12日土曜日

Page 93: 世界一言語トークス by Python

大事

2009年12月12日土曜日

Page 94: 世界一言語トークス by Python

世界一使いやすい言語にしようとGuido が頑張っていて、その思考が感じれる言語

2009年12月12日土曜日

Page 95: 世界一言語トークス by Python

ご静聴ありがとうございました

2009年12月12日土曜日