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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Eloy Zuniga Jr.
June 19, 2012
Technology
8
640
Python Decorators
A basic understanding of Python Decorators.
Eloy Zuniga Jr.
June 19, 2012
Tweet
Share
More Decks by Eloy Zuniga Jr.
See All by Eloy Zuniga Jr.
The Filter Function
eloy
0
76
The `max` function
eloy
0
60
The Command Line Interface
eloy
2
490
Other Decks in Technology
See All in Technology
IaaS/SaaS管理における SREの実践 - SRE Kaigi 2026
bbqallstars
4
1.7k
2026年はチャンキングを極める!
shibuiwilliam
9
1.9k
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
100
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
3
430
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.1k
Deno・Bunの標準機能やElysiaJSを使ったWebSocketサーバー実装 / ラーメン屋を貸し切ってLT会! IoTLT 2026新年会
you
PRO
0
290
usermode linux without MMU - fosdem2026 kernel devroom
thehajime
0
210
プロポーザルに込める段取り八分
shoheimitani
1
160
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
5
760
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
クレジットカード決済基盤を支えるSRE - 厳格な監査とSRE運用の両立 (SRE Kaigi 2026)
capytan
6
2.5k
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
Featured
See All Featured
Building Adaptive Systems
keathley
44
2.9k
Abbi's Birthday
coloredviolet
1
4.7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Odyssey Design
rkendrick25
PRO
1
490
Information Architects: The Missing Link in Design Systems
soysaucechin
0
770
How to build a perfect <img>
jonoalderson
1
4.9k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
Code Reviewing Like a Champion
maltzj
527
40k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
430
A Soul's Torment
seathinner
5
2.2k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
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