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
Python-intro-2
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Shuai Liu
December 23, 2014
Programming
82
0
Share
Python-intro-2
Shuai Liu
December 23, 2014
More Decks by Shuai Liu
See All by Shuai Liu
Auto-Layout.pdf
liushuaikobe
2
130
Python-intro-1
liushuaikobe
0
78
GitRadar——毕业论文答辩
liushuaikobe
0
200
NoSQL & MongoDB
liushuaikobe
0
180
Other Decks in Programming
See All in Programming
SkillsをS3 Filesに置く時のあれこれ
watany
3
1.6k
TSKaigi2026-静的解析への投資がAI時代のコード品質を支える ── カスタムESLintルールの設計と運用
hayatokudou
2
160
ReactとSvelteのその先、Ripple-TS / Beyond React and Svelte: Ripple-TS
ssssota
0
190
Firefoxにコントリビューションして得られた学び
ken7253
2
160
ECR拡張スキャンでSBOMを収集して サプライチェーン攻撃の影響調査を 爆速で終わらせてみた
akihisaikeda
1
120
20260514_its_the_context_window_stupid.pdf
heita
0
1k
Are We Really Coding 10× Faster with AI?
kohzas
0
190
【ディップ|26年新卒研修資料】OpenAPI/Swagger REST API研修
dip_tech
PRO
0
170
Back to the roots of date
jinroq
0
870
運転動画を検索可能にする〜Cosmos-Embed1とDatabricks Vector Searchで〜/cosmos-embed1-databricks-vector-search
studio_graph
3
960
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
500
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
720
Featured
See All Featured
The Curse of the Amulet
leimatthew05
1
12k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
Everyday Curiosity
cassininazir
0
210
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
300
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.3k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Code Review Best Practice
trishagee
74
20k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
140
The Pragmatic Product Professional
lauravandoore
37
7.3k
Mind Mapping
helmedeiros
PRO
1
190
Transcript
Intro to Python by Shuai Liu
agenda • History & Basics • Advanced & Be Pythonic
• Awesome Python Frameworks
Advanced & Be Pythonic
Review • int & float & bool • string &
list & tuple • dict • loop & branch • def methods
Something interesting…
def foo(a, b): """My niubility methods.""" return a + b
"""My niubility methods.""" >>> print foo.__doc__ >>> My niubility methods.
class Person(object): """My first class""" version = 1.0 def __init__(self,
name): self.name = name print "__init__ called" def get_name(self): """Return the name""" return self.name
Pythonic
–Martijn Faassen, founder of the lxml (XML library for Python)
“Pythonic is to use the Python constructs and datastructures with clean, readable idioms.”
enumerate l = [0, 1, 2, 3, 4] for i
in range(len(l)): print i, l[i] for i, element in enumerate(l): print i, element
value exchange temp = foo foo = bar bar =
temp foo, bar = bar, foo
string concatenating s = “hello” + “world” s = “”.join([“hello”,
“world”])
λ
lambda def foo(x): return x ** 2 lambda x :
x ** 2 >>> a = lambda x : x ** 2 >>> a(5) >>> 25
filter & map & reduce
>>> filter(function, iterable) >>> map(function, iterable) >>> reduce(function, iterable)
filter
map
reduce
None
List comprehensions
>>> a = map(lambda x : x ** 2, range(10))
>>> a = [ x ** 2 for x in range(10)] >>> a = filter(lambda x : x % 2, range(10)) >>> a = [x for x in range(10) if x % 2]
None
two more things…
PEP
Python Enhancement Proposals num title owner 1 PEP Purpose and
Guidelines Warsaw, Hylton, Goodger, Coghlan 4 Deprecation of Standard Modules von Löwis 5 Guidelines for Language Evolution Prescod 8 Style Guide for Python Code GvR, Warsaw, Coghlan
pip
pip • A tool for installing and managing Python packages.
• $ sudo pip install Requests
Resources
None
IDE ‘+’.join([ , ])
IDE
Summary • OO • lambda & three functions • list
comprehensions • resources
Thanks