$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python-intro-2
Search
Shuai Liu
December 23, 2014
Programming
0
74
Python-intro-2
Shuai Liu
December 23, 2014
Tweet
Share
More Decks by Shuai Liu
See All by Shuai Liu
Auto-Layout.pdf
liushuaikobe
2
130
Python-intro-1
liushuaikobe
0
71
GitRadar——毕业论文答辩
liushuaikobe
0
180
NoSQL & MongoDB
liushuaikobe
0
160
Other Decks in Programming
See All in Programming
sbt 2
xuwei_k
0
300
Developing static sites with Ruby
okuramasafumi
0
310
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.9k
TestingOsaka6_Ozono
o3
0
170
Microservices rules: What good looks like
cer
PRO
0
1.5k
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
1.3k
AIエージェントの設計で注意するべきポイント6選
har1101
5
870
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
130
Deno Tunnel を使ってみた話
kamekyame
0
150
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
430
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.8k
愛される翻訳の秘訣
kishikawakatsumi
3
330
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.7k
My Coaching Mixtape
mlcsv
0
6
Designing for humans not robots
tammielis
254
26k
Rails Girls Zürich Keynote
gr2m
95
14k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
28
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
83
Building an army of robots
kneath
306
46k
From π to Pie charts
rasagy
0
86
The SEO Collaboration Effect
kristinabergwall1
0
300
Optimising Largest Contentful Paint
csswizardry
37
3.5k
The SEO identity crisis: Don't let AI make you average
varn
0
32
So, you think you're a good person
axbom
PRO
0
1.8k
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