python overview
TRANSCRIPT
![Page 1: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/1.jpg)
Pythonを眺めてみる
yassu
2015/07/25 (Sat)
yassu Python を眺めてみる 2015/07/25 (Sat) 1 / 21
![Page 2: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/2.jpg)
お前だれよ
名前: yassu[0320]職業: 某大学院数学科 M2 (専攻: 特異点論)Python歴: 3年くらい
Vim使い
yassu Python を眺めてみる 2015/07/25 (Sat) 2 / 21
![Page 3: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/3.jpg)
PyCon mini @ sapporo
Figure : pycon_mini.jpg
yassu Python を眺めてみる 2015/07/25 (Sat) 3 / 21
![Page 4: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/4.jpg)
Agenda
Pythonとは?Pythonの利点と欠点
Pythonのライブラリ
Pythonが使われているプロジェクト
PEPSPythonの禅
yassu Python を眺めてみる 2015/07/25 (Sat) 4 / 21
![Page 5: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/5.jpg)
Pythonとは?
凡庸プログラミング言語
ドイツ人の Guido van Rossum によって作られた
モンティ・パイソンというアニメから言語名は命名された
ヘビのアイコンが目印
Rubyのお兄さん的存在
yassu Python を眺めてみる 2015/07/25 (Sat) 5 / 21
![Page 6: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/6.jpg)
Pythonの利点と欠点
コードのリーダビリティが高くなるように言語が設計されて
いると主張されている
型付けが弱い
(Cに比べると)遅い
Pythonの標準的なコーディング規約なる Pep8もの存在する.“出来るだけ同じコードとして書けるなら、同じように書いた
方がいい”
yassu Python を眺めてみる 2015/07/25 (Sat) 6 / 21
![Page 7: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/7.jpg)
Pythonの利点と欠点 (2)
カプセル化の概念がない
インターフェースの概念が後付け (duck typing, “それがアヒ
ルのように歩き、アヒルのように鳴くのなら、それはアヒル
である”)python 2.x から 3.x への移行で少々の変更が加えられた
yassu Python を眺めてみる 2015/07/25 (Sat) 7 / 21
![Page 8: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/8.jpg)
コードを眺めてみる
初めての Pythonプログラム (dive into python3)
yassu Python を眺めてみる 2015/07/25 (Sat) 8 / 21
![Page 9: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/9.jpg)
Pythonのライブラリ
numpy: 数値計算モジュール
matploblib: グラフ作成ライブラリ
sympy: 科学計算, 数値計算ライブラリ (pure python)pandas: データ解析のライブラリ
scipy: 科学計算・数値計算ライブラリ
Django: Web フレームワーク
Blender: 3D, アニメーション, ゲーム制作環境
PILLOW: 画像処理ライブラリ
yassu Python を眺めてみる 2015/07/25 (Sat) 9 / 21
![Page 10: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/10.jpg)
Pythonが使われているプロジェクト
reStructuredText (RST): グラフィカルなmarkdownみたいなの
Sphinx (およびそのプラグイン): 構造的でもっとすごい rstみたいなの
SCons: Pythonで書けるMakefile的なもの
TracSage: 数式処理システム. pythonのライブラリでもある.Impressiveblockdiag (およびそのプラグイン): シンプルなテキストから
ブロック図を生成する ブロック図生成ツール
vint: vimの lint
yassu Python を眺めてみる 2015/07/25 (Sat) 10 / 21
![Page 11: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/11.jpg)
What is PEPS ?
以後 Ref: “パーフェクト Python”Pythonの設計のプロセスを可視化していき, 実装の前に皆の
意見を得ることを目的とする
yassu Python を眺めてみる 2015/07/25 (Sat) 11 / 21
![Page 12: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/12.jpg)
重要なところ
PEP 0 (Indenx of Python Enhancement Proposals): PEPの目次
PEP 1 (PEP Purpose and Guidelines): PEPについてのガイド
ライン
PEP 5 (Guidelines for Language Evolution): 後方互換精を崩す
際の決め事
PEP 8 (Style Guide for Python Code): 標準のコーディング規約
yassu Python を眺めてみる 2015/07/25 (Sat) 12 / 21
![Page 13: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/13.jpg)
Pythonの禅
>>> import this
yassu Python を眺めてみる 2015/07/25 (Sat) 13 / 21
![Page 14: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/14.jpg)
Beautigul is better than ugly. (醜悪より美しいほ
うが良い)
コードを “美しく”保つ “ことは, 少々開発が遅くなることよ
り大事.
yassu Python を眺めてみる 2015/07/25 (Sat) 14 / 21
![Page 15: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/15.jpg)
Explicit is better than implicit. (暗黙より明示す
るほうが良い)
例えば
>>> from re import *
よりも
>>> from re import search, compile
Pythonでは暗黙的な変数の使用も許されない.ただし, ipythonでの_のように, 例外もある.
yassu Python を眺めてみる 2015/07/25 (Sat) 15 / 21
![Page 16: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/16.jpg)
Flat is better than nested . (ネストしたものより
フラットなほうが良い)例えばモジュール名は xxx.yyy.zzz ではなく xxx_yyy_zzzなどと
する.
if A:if B:
xxxelif C:
yyy
よりも
if A and B:xxx
elif A and C:yyy
Special cases aren’t special enough to break rules. (特別
だと思うものもルールをやるぶほど特別ではない)Ex: staticmethod と classmethodの例
yassu Python を眺めてみる 2015/07/25 (Sat) 16 / 21
![Page 17: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/17.jpg)
In the face of ambiguity, refuse the temptation toguess. (曖昧なモノに出くわしたら推測しては
いけない)
1 + ”0” は 1ではない.
yassu Python を眺めてみる 2015/07/25 (Sat) 17 / 21
![Page 18: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/18.jpg)
There should be one- and preferably only one-obvious way to do it. (1つのことをするのに, いろいろなやり方は好ましくない)
いろいろな人がみんな知らない特殊なプログラムの書き方を
している状況を想像してみよう
yassu Python を眺めてみる 2015/07/25 (Sat) 18 / 21
![Page 19: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/19.jpg)
if the implementation is easy to explain, it’s goodidea. (実装の説明が簡単? そのアイデアは良い
のでしょう)
程よくシンプルに書けているというのはいいこと.
yassu Python を眺めてみる 2015/07/25 (Sat) 19 / 21
![Page 20: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/20.jpg)
Namespaces are one honking gread idea - let’s domore of thosse ! (ネームスペースはすごく良い
アイデアの1つ. もっと考えよう)
ネームスペースによって値のコンフリクト (衝突)のミスが少ない
プログラムが書けるようになるだろう.
yassu Python を眺めてみる 2015/07/25 (Sat) 20 / 21
![Page 21: Python overview](https://reader033.vdocuments.site/reader033/viewer/2022042821/55d39759bb61eb49478b465a/html5/thumbnails/21.jpg)
ありがとうございました.
yassu Python を眺めてみる 2015/07/25 (Sat) 21 / 21