Upload
yoshiori-shoji
View
1.421
Download
1
Embed Size (px)
Citation preview
世界一言語トークスby PythonYoshiori SHOJI
2009年12月14日月曜日
世界一言語トークスby PythonYoshiori SHOJI
裏
2009年12月14日月曜日
注意このプレゼンに登場する
考え方は大変 Python 的ではありません。
ご注意ください。
2009年12月14日月曜日
2009年12月14日月曜日
自 己紹 介
2009年12月14日月曜日
庄司嘉
織2009年12月14日月曜日
庄司嘉
織2009年12月14日月曜日
vaJ a第 一 言 語
2009年12月14日月曜日
vaJ a第 一 言 語
2009年12月14日月曜日
u assa kar b
.
2009年12月14日月曜日
u assa kar b
.
2009年12月14日月曜日
2009年12月14日月曜日
インデントがブロックってキモイ!!
2009年12月14日月曜日
確かにPython はインデントを用いたブロック構造なので
def hoge(): print 'foo' print 'bar'
2009年12月14日月曜日
確かにPython はインデントを用いたブロック構造なので
def hoge(): print 'foo' print 'bar'
def hoge(): print 'foo' print 'bar'
2009年12月14日月曜日
確かにPython はインデントを用いたブロック構造なので
def hoge(): print 'foo' print 'bar'
def hoge(): print 'foo' print 'bar'X2009年12月14日月曜日
でも!!
2009年12月14日月曜日
λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ λ
lambda があるじゃないか!!
2009年12月14日月曜日
でも!?
2009年12月14日月曜日
2009年12月14日月曜日
「文」な困ったちゃん
2009年12月14日月曜日
「文」な困ったちゃん• Python では代入が文•ちょw (再)代入出来ないwwまぁ、関数型っぽくて良いか
2009年12月14日月曜日
「文」な困ったちゃん• Python では代入が文•ちょw (再)代入出来ないwwまぁ、関数型っぽくて良いか
• print が文•ちょw デバッグ出来ねぇwwww
2009年12月14日月曜日
というか
•処理が続けて書けないw• foo() bar() って文じゃんwwww
2009年12月14日月曜日
2009年12月14日月曜日
比較式• if 文とかで使うアレif( A && B ) とか if A and B
• A and B (&&)A を評価して真だったら B を評価
• A or B ( || )A を評価して偽だったら B を評価
2009年12月14日月曜日
irb(main):014:0> p 1 && 2 2=> nilirb(main):015:0> p 1 || 2 1=> nil
比較式
>>> print 1 and 22>>> print 1 or 21
2009年12月14日月曜日
irb(main):014:0> p 1 && 2 2=> nilirb(main):015:0> p 1 || 2 1=> nil
比較式
>>> print 1 and 22>>> print 1 or 21
これじゃね?
2009年12月14日月曜日
Python の真偽値Python では None、 False、ゼロ(数値)、 空配列、空辞書、
及びユーザ定義クラスで __nonzero__() や __len__() が
数値 zero または False を返す場合は偽として扱われます。
それ以外は真として扱われます。
2009年12月14日月曜日
複数の処理を式に
2009年12月14日月曜日
foo() and bar()複数の処理を式に
2009年12月14日月曜日
foo() and bar()左辺が"真"だと右辺が実行される
式になった!!
複数の処理を式に
2009年12月14日月曜日
foo() and bar()左辺が"真"だと右辺が実行される
式になった!!でも
左辺の評価結果が常に"真"にならないと困る
複数の処理を式に
2009年12月14日月曜日
foo() and bar()左辺が"真"だと右辺が実行される
式になった!!でも
左辺の評価結果が常に"真"にならないと困る
[ foo() ] and bar()
複数の処理を式に
2009年12月14日月曜日
foo() and bar()左辺が"真"だと右辺が実行される
式になった!!でも
左辺の評価結果が常に"真"にならないと困る
[ foo() ] and bar()[ ] で囲む事によって要素数 1 のリストになり
常に"真"になる
複数の処理を式に
2009年12月14日月曜日
さらに
2009年12月14日月曜日
[ foo() ] and bar()
さらに
2009年12月14日月曜日
[ foo() ] and bar()
ただの連続処理なら一気に初期化しちゃえばいい
さらに
2009年12月14日月曜日
[foo(), bar(), hoge(),]
[ foo() ] and bar()
ただの連続処理なら一気に初期化しちゃえばいい
さらに
2009年12月14日月曜日
if 文を式にif A : foo() bar()
2009年12月14日月曜日
[ foo() ] and [ bar() ] if A else True
if 文を式にif A : foo() bar()
2009年12月14日月曜日
[ foo() ] and [ bar() ] if A else True2.5から三項演算子が出来たのでそれを使う
if 文を式にif A : foo() bar()
2009年12月14日月曜日
if 文を式に(2)
2009年12月14日月曜日
if 文を式に(2)[[ foo() ] and [ bar() ] if A else True ]
2009年12月14日月曜日
if 文を式に(2)[[ foo() ] and [ bar() ] if A else True ]
これ自体も[ ] で囲む事によって常に"真"になる
2009年12月14日月曜日
[A and [ foo() ] and [ bar() ]]
2.5以前は三項演算子が無かったので
if 文を式に(2)[[ foo() ] and [ bar() ] if A else True ]
これ自体も[ ] で囲む事によって常に"真"になる
2009年12月14日月曜日
for文を式に
2009年12月14日月曜日
Python にはリスト内包表記が有る!!
for文を式に
2009年12月14日月曜日
Python にはリスト内包表記が有る!!
for文を式に
for x in range(10) : foo( x )
2009年12月14日月曜日
Python にはリスト内包表記が有る!!
for文を式に
for x in range(10) : foo( x )
[ foo( x ) for x in range(10) ]
2009年12月14日月曜日
関数の返り値
2009年12月14日月曜日
def hoge( data ): return [foo()] and bar( data )
関数の返り値
2009年12月14日月曜日
def hoge( data ): return [foo()] and bar( data )最初に return 書けば最後に評価した値が返る
関数の返り値
2009年12月14日月曜日
def hoge( data ): return [foo()] and bar( data )最初に return 書けば最後に評価した値が返る
関数の返り値
lambda 化hoge = lambda data :([foo()] and bar( data ) )
2009年12月14日月曜日
tipsprint 文は
代入はリストの append や辞書の__setitem__を使用する。グローバルな名前空間globals()、ローカルの名前空間locals()、そしてオブジェクトxの名前空間x.__dict__
2009年12月14日月曜日
tipsimport sys;[sys.stdout.write(data)]print 文は
代入はリストの append や辞書の__setitem__を使用する。グローバルな名前空間globals()、ローカルの名前空間locals()、そしてオブジェクトxの名前空間x.__dict__
globals().__setitem__("setitem", globals().__setitem__)
2009年12月14日月曜日
2009年12月14日月曜日
で
2009年12月14日月曜日
実際にやってみた(某美人時計の画像ぶっこぬき編)
import sys,os,urllib,time;[[[globals().__setitem__('url','http://www.bijint.com/jp/img/photo/%02d%02d.jpg' % (i, j))] and [globals().__setitem__('file',open(os.path.basename(url), 'wb'))] and [file.write(urllib.urlopen(url).read())] and [file.close()] and [time.sleep(5)] for j in range(60)] for i in range(24)]
2009年12月14日月曜日
実際にやってみた(fizbuzネタ編)
import sys;[globals().__setitem__("setitem", globals().__setitem__)] and [setitem('isSun',lambda : sys.platform.find('java') > -1)] and [setitem('p',lambda data :(isSun() and ([globals().__setitem__('java',__import__('java'))] and [java.lang.System.out.write(java.lang.String(data).getBytes("utf-8"))] and [sys.stdout.write('\n')]) or [sys.stdout.write(data + '\n')]))] and [setitem('fizbuz',lambda i :([setitem('fiz','Fiz')] and [setitem('buz','Buz')] and [setitem('ret','')] and [isSun() and ([setitem('fiz','ふぃずぅ')] and [setitem('buz','ばずぅ')])] and [i % 3 == 0 and setitem('ret', globals().get('ret') + fiz)] and [i % 5 == 0 and setitem('ret', globals().get('ret') + buz)] and [len(globals().get('ret')) == 0 and setitem('ret', str(i))] and ret))] and [p(fizbuz(i)) for i in xrange(20)]
2009年12月14日月曜日
全部式だからPythonなのに
フリーレイアウト!!
2009年12月14日月曜日
インデントがブロックってキモイ!!
2009年12月14日月曜日
インデントがブロックってキモイ!!
別にインデント使わないで書けばいじゃん
2009年12月14日月曜日
ご清聴ありがとうございました
2009年12月14日月曜日