22 lines
468 B
Python
22 lines
468 B
Python
def make_pretty(func):
|
|
# define the inner function
|
|
def inner():
|
|
# add some additional behavior to decorated function
|
|
print("I got decorated")
|
|
|
|
# call original function
|
|
func()
|
|
# return the inner function
|
|
return inner
|
|
|
|
# define ordinary function
|
|
@make_pretty
|
|
def ordinary():
|
|
print("I am ordinary")
|
|
|
|
# decorate the ordinary function
|
|
decorated_func = make_pretty(ordinary)
|
|
|
|
# call the decorated function
|
|
ordinary()
|