Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Starting Python
Search
Kentaro Kawano
July 10, 2017
Programming
0
32
Starting Python
Pythonを始められるような基本的なところ
Kentaro Kawano
July 10, 2017
Tweet
Share
More Decks by Kentaro Kawano
See All by Kentaro Kawano
Goでのレシーバーとnilの関係 / Receiver and nil relationship in Go
kawaken
0
380
Goの時刻に関するテスト/Testing time in Go
kawaken
0
36
AWS Lambda + Go
kawaken
0
31
goaのdesignをラクに書く/Write goa design easily
kawaken
0
27
Goでのチーム開発とコード管理の悩み/Team development and code management in Go
kawaken
0
34
Pyvmomiとansibleのdynamic inventory
kawaken
0
38
Other Decks in Programming
See All in Programming
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
5
1.7k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
280
現場で役立つモデリング 超入門
masuda220
PRO
15
3.2k
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
受け取る人から提供する人になるということ
little_rubyist
0
230
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
190
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
as(型アサーション)を書く前にできること
marokanatani
8
2.6k
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
136
6.6k
Typedesign – Prime Four
hannesfritz
40
2.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
670
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Scaling GitHub
holman
458
140k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Transcript
Pythonͷ࢝Ίํ
࠷ۙPython͕Γ্͕͍ͬͯΔ
201511݄Ҏ߱(46த)
Δ͔͠ͳ͍ʂ ͜ͷϏοάΣʔϒʹʂ
CentOSͳΒPython͕ΠϯετʔϧࡁΈ $ python Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "Hello World" Hello World >>> exit()
͓ΘΓ
ͱ͍͏༁ʹ͍͔ͳ͍
CentOSͰ όʔδϣϯ͕ݹ͍
PythonͷόʔδϣϯҠߦʹ͍ͭͯ ɺ͍͜ͱͬͯΔͱͯ͠৭ʑ ࢥ͏ͱ͜Ζ͕͋Γ·͢ɻ͜ͷ͘ ͳΔͷͰࠓׂѪ͢Δ͚Ͳɺͱʹ͔ ͘ࠓʮPython3ܥΛ͏ʯͷ͕ྑ͍ Ͱ͢ɻͰɺAWSLambda2ܥͰπ ϥΠɻGoΛ͍·͠ΐ͏ɻ
None
Πϯετʔϧ(OLD) • xbuild ͕ศར $ git clone https://github.com/tagomoris/xbuild.git $ cd
xbuild $ ./python-install 3.5.2 ~/local/python-3.5.2
Πϯετʔϧ • ඪ४ͷΠϯετʔϥʔΛ͍·͠ΐ͏ • https://www.python.org/downloads/ • ࠷৽ 3.6.0 • όʔδϣϯϚωʔδϟෆཁʢޙड़ʣ
SDKͷόʔδϣϯཧ ෳͷPythonΛΠϯετʔϧ͢Δͱ… % ls /usr/local/bin/python3* /usr/local/bin/python3@ /usr/local/bin/python3.5m-config@ /usr/local/bin/python3-32@ /usr/local/bin/python3.6@ /usr/local/bin/python3-config@
/usr/local/bin/python3.6-32@ /usr/local/bin/python3.5@ /usr/local/bin/python3.6-config@ /usr/local/bin/python3.5-32@ /usr/local/bin/python3.6m@ /usr/local/bin/python3.5-config@ /usr/local/bin/python3.6m-config@ /usr/local/bin/python3.5m@ ͜͏ͳΔɻ
ݸผͷϓϩδΣΫτͷόʔδϣϯʁ • venv ΛͬͯSDKࣗମΛόϯυϧ͢Δ % pwd /Users/kekawano/hoge % python3.5 -m
venv venv % ls venv/ % ls venv/ bin/ include/ lib/ pip-selfcheck.json pyvenv.cfg
venv ͷ͍ํ • όʔδϣϯͷݻఆ • ͍͍ͨpython -m venv σΟϨΫτϦ໊ •
༗ޮԽ • source σΟϨΫτϦ໊/bin/activate • ແޮԽ • deactivate
ྫ % which python /usr/bin/python % source venv/bin/activate % which
python /Users/kekawano/hoge/venv/bin/python % python -V Python 3.5.1 % deactivate % python -V Python 2.7.10
ύοέʔδཧ • pip Λ͏ % which pip /Users/kekawano/hoge/venv/bin/pip % pip
install flask % pip show flask ... Location: /Users/kekawano/hoge/venv/lib/python3.5/site-packages ... • venv Ͱڥ͕ด͍ͯ͡ΔͷͰGlobalʹӨڹ͠ͳ͍ • PyPI - the Python Package Index : Python Package Index
؆୯ͳWebΞϓϦ from flask import Flask app = Flask(__name__) @app.route("/") def
hello(): return "Hello world!" if __name__ == "__main__": app.run()
Pythonͷಛ • ಈతܕ͚ݴޠ • Indented Block • ܭࢉͷϥΠϒϥϦ๛
࠷ۙͷPython • ඇಉظॲཧʹରԠ async/await • จࣈྻͷf-string • type hinting
ύοέʔδ • module = file • mod1.py • package =
directory • mod2/init.py
࣮ߦ python mod1.py python mod2 • mod2/main.py