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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Eloy Zuniga Jr.
June 19, 2012
Technology
640
8
Share
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
83
The `max` function
eloy
0
66
The Command Line Interface
eloy
2
500
Other Decks in Technology
See All in Technology
自称宇宙最速で不合格となったAIP-C01にリベンジを果たすべくAIで問題集アプリを作ってみた。
yama3133
0
140
AIが変えた"品質の守り方"
kkakizaki
10
2.9k
「使われるデータ基盤」を目指してデータアナリストとワークショップをやった話
jackojacko_
2
860
Gradle×GitHub_ActionsでCI時間を約50%短縮 ジョブ分割の設計と落とし穴 / Cutting CI Time by ~50% with Gradle and GitHub Actions: Job-Splitting Design and Pitfalls
takatty
0
130
CARTA HOLDINGS エンジニア向け 採用ピッチ資料 / CARTA-GUIDE-for-Engineers
carta_engineering
0
47k
Claude Code x Accounting
kawaguti
PRO
1
320
Amazon CloudFrontにおけるAIボットアクセス制御のポイント
kizawa2020
4
270
はじめてのAI-DLC
yoshidashingo
2
530
JJUG CCC 2026 Spring AI時代の開発こそ標準化を武器に! ― 方式・プロセス・プラットフォームの標準化
s27watanabe
2
280
【ハノーバーメッセ振り返りイベントat名古屋】データは集約からAI起点の収集に ~組織内・組織間でのデータ連携~
tanakaseiya
0
120
まだ道半ば、AI-DLCを歩み始めている話
news_it_enj
2
180
生成AIに振り回されない 〜確率論と決定論の使い分け〜
shukob
0
110
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Ethics towards AI in product and experience design
skipperchong
2
280
Balancing Empowerment & Direction
lara
6
1.1k
Everyday Curiosity
cassininazir
0
210
Typedesign – Prime Four
hannesfritz
42
3k
The Limits of Empathy - UXLibs8
cassininazir
1
340
A designer walks into a library…
pauljervisheath
211
24k
Mobile First: as difficult as doing things right
swwweet
225
10k
How to make the Groovebox
asonas
2
2.2k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
300
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
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