Verzeichnis für teil28

This commit is contained in:
Olli Graf
2024-10-25 14:03:27 +02:00
parent af36c44e66
commit fec0969d7f
12 changed files with 2 additions and 0 deletions

21
teil28/simpledecorator.py Normal file
View File

@@ -0,0 +1,21 @@
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()