You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
495 B
21 lines
495 B
1 month ago
|
def make_pretty(func):
|
||
|
# define the inner function
|
||
|
def inner():
|
||
|
# add some additional behavior to decorated function
|
||
1 month ago
|
print("Dies ist die innere Funktion.")
|
||
1 month ago
|
|
||
|
# call original function
|
||
|
func()
|
||
|
# return the inner function
|
||
|
return inner
|
||
|
|
||
|
# define ordinary function
|
||
|
def ordinary():
|
||
1 month ago
|
print("Dies ist die ordinary() Funktion.")
|
||
1 month ago
|
|
||
|
# decorate the ordinary function
|
||
|
decorated_func = make_pretty(ordinary)
|
||
|
|
||
|
# call the decorated function
|
||
|
decorated_func()
|