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
8
630
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
74
The `max` function
eloy
0
60
The Command Line Interface
eloy
2
490
Other Decks in Technology
See All in Technology
アプリにAIを正しく組み込むための アーキテクチャ── 国産LLMの現実と実践
kohju
0
240
"人"が頑張るAI駆動開発
yokomachi
1
630
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
9.9k
Amazon Bedrock Knowledge Bases × メタデータ活用で実現する検証可能な RAG 設計
tomoaki25
6
2.5k
2025年のデザインシステムとAI 活用を振り返る
leveragestech
0
360
ESXi のAIOps だ!2025冬
unnowataru
0
400
LayerX QA Night#1
koyaman2
0
270
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
480
フィッシュボウルのやり方 / How to do a fishbowl
pauli
2
400
2025-12-18_AI駆動開発推進プロジェクト運営について / AIDD-Promotion project management
yayoi_dd
0
170
日本Rubyの会: これまでとこれから
snoozer05
PRO
6
250
ECS_EKS以外の選択肢_ROSA入門_.pdf
masakiokuda
0
110
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
200
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
The agentic SEO stack - context over prompts
schlessera
0
570
AI: The stuff that nobody shows you
jnunemaker
PRO
1
29
Balancing Empowerment & Direction
lara
5
820
The Mindset for Success: Future Career Progression
greggifford
PRO
0
200
Building an army of robots
kneath
306
46k
30 Presentation Tips
portentint
PRO
1
180
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