243 bytes of Python
Created 17 hours ago
— expires in 7 days
Viewed
58 times
https://dpaste.com/F8J8GYFBZ
| # Understand Decorators in 30 seconds:
## Given:
def decorator(fn):
fn.foo = true
return fn
## Then
def myfunc(...):
...
myfunc = decorator(myfunc)
## IS IDENTICAL TO
@decorator
def myfunc(...):
...
|
# Understand Decorators in 30 seconds:
## Given:
def decorator(fn):
fn.foo = true
return fn
## Then
def myfunc(...):
...
myfunc = decorator(myfunc)
## IS IDENTICAL TO
@decorator
def myfunc(...):
...