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
89
The `max` function
eloy
0
69
The Command Line Interface
eloy
2
510
Other Decks in Technology
See All in Technology
第67回コンピュータビジョン勉強会CVPR2026読会前編
tsukamotokenji
0
160
Vポイント分析基盤におけるデータモデリング20年史
taromatsui_cccmkhd
4
670
20260720_クラウド女子会×PyLadiesTokyoコラボ Amazon Bedrock ハンズオン用資料
yuuka51
1
100
JAWS_ICEBERG_BASECAMP
iqbocchi
2
100
複数プロダクト組織のAIネイティブ化における戦略 / AICon2026_kude
rakus_dev
0
280
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
570
凡エンジニアがこの先生きのこるためには。〜TypeScript完全に理解したい〜
alchemy1115
2
400
AI時代のYAGNI:「爆速で無駄になった機能」からの学び / 20260720 Naoki Takahashi
shift_evolve
PRO
3
500
AI時代におけるテストの基礎の再定義 / Rethinking the Fundamentals of Testing in the AI Era
mineo_matsuya
4
1k
『モデル + ハーネス』で読み解く AIエージェント入門
oracle4engineer
PRO
2
150
DatabricksにおけるMCPソリューション
taka_aki
1
330
AI時代のPlaywright活用(システムテストを自動化する ー 実行エンジンにPla ywrightを選んだ理由)
ynisqa1988
2
900
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
640
Faster Mobile Websites
deanohume
310
32k
Evolving SEO for Evolving Search Engines
ryanjones
0
240
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
380
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Utilizing Notion as your number one productivity tool
mfonobong
4
440
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
340
Designing for Performance
lara
611
70k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
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