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 Decorators
Search
Eloy Zuniga Jr.
June 19, 2012
Technology
640
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python Decorators
A basic understanding of Python Decorators.
Eloy Zuniga Jr.
June 19, 2012
More Decks by Eloy Zuniga Jr.
See All by Eloy Zuniga Jr.
The Filter Function
eloy
0
91
The `max` function
eloy
0
69
The Command Line Interface
eloy
2
520
Other Decks in Technology
See All in Technology
SO-101×VLAによる3色キューブのピック&プレース
abeja
0
220
ハーレムエンジニアリング
kazuma777777
0
190
AIに狂うスタートアップが、あえて「人との協働」に全振りした新卒エンジニア研修 / New Graduate Engineer Training at a Startup Accelerating AI Adoption
ohnoeight
0
160
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
19k
My broken English still works: speaking at global OSS events
naruoga
0
120
Kiro入門|仕様駆動開発で変わるAI時代の開発スタイル
cmkudo
0
210
関東Kaggler会発表資料
takoi
1
260
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
350
小粒でもパワフルなJS Runtime Antjsについて
comamoca
0
110
【AG-UI × A2UI × MCP Apps】Generative UIをやさしく解説する
nrinetcom
PRO
1
150
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
24k
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
260
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
660
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
290
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
450
The Cost Of JavaScript in 2023
addyosmani
55
10k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
300
Claude Code のすすめ
schroneko
67
230k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Transcript
Decorators What are they? How to explain them. Tuesday, June
19, 12
Tuesday, June 19, 12
Basic definition Decorator is a function that takes a function
as a parameter and returns a function Tuesday, June 19, 12
Basic definition Decorator is a function that takes a function
as a parameter and returns a function Is a function. Takes a function. Returns a function Tuesday, June 19, 12
func = func_hugger(func) Illustration Tuesday, June 19, 12
def in_bed(func): def f(): return ‘%s In bed.’ % func()
return f Change output Tuesday, June 19, 12
def in_bed(func): def f(): if f.in_pool: return ‘%s In pool.’
% func() return ‘%s In bed.’ % func() f.in_pool = False return f Add attributes Tuesday, June 19, 12
def in_bed(func): def f(*args, **kwargs): if args or kwargs: raise
Exception(‘wat?’) return ‘%s In bed.’ % func() return f Validate Tuesday, June 19, 12
Tuesday, June 19, 12
Basic definition Is a function. Takes a function. Returns a
function Tuesday, June 19, 12
Syntactic Sugar Annotation Syntax Tuesday, June 19, 12
Syntactic Sugar Annotation Syntax @func Tuesday, June 19, 12
def luke_quote(): return “I’m Luke SkyWalker, I’m here to rescue
you.” Decorate Tuesday, June 19, 12
def luke_quote(): return “I’m Luke SkyWalker, I’m here to rescue
you.” Decorate @in_bed Tuesday, June 19, 12
def luke_quote(): return “I’m Luke SkyWalker, I’m here to rescue
you.” Decorate @in_bed @no_inbreeding Tuesday, June 19, 12
def luke_quote(): return “I’m Luke SkyWalker, I’m here to rescue
you.” Decorate @in_bed(with=”lightsaber”) @in_bed Tuesday, June 19, 12
Tuesday, June 19, 12
@eloy Tuesday, June 19, 12