Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Python Decorators
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Eloy Zuniga Jr.
June 19, 2012
Technology
650
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
92
The `max` function
eloy
0
69
The Command Line Interface
eloy
2
520
Other Decks in Technology
See All in Technology
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
170
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
410
CSS2026:OWS研究会・招待講演「世界観を、実装する」
atsush1_sada
2
260
顧客価値を追いかけたら、プライシングにたどり着いた
sansantech
PRO
2
790
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
380
Kiro Crewで「みのるん式」仕事術やってみた
minorun365
PRO
3
1.1k
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
430
Microsoft のサポート ライフサイクルを理解する
murachiakira
PRO
0
140
CloudWatch Logsのコスト最適化:どこまでAIに任せてどこから人間が承認すべきか
yama3133
0
170
QAエンジニアがSoutherを使ってみたの〜10分でわかるSouther〜
mhlyc
0
110
Let's Change Our World—Again
snoozer05
PRO
6
480
AWSセキュリティで活用するAI機能
cmusudakeisuke
1
250
Featured
See All Featured
Believing is Seeing
oripsolob
1
250
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
610
Leo the Paperboy
mayatellez
10
2.4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
280
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Paper Plane (Part 1)
katiecoart
PRO
2
12k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
590
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
GraphQLとの向き合い方2022年版
quramy
50
15k
Un-Boring Meetings
codingconduct
0
460
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
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