uni-repo/dekorator/beispiel2.py

21 lines
342 B
Python

def my_decorator_with_args(surrounding_text):
def actual_decorator(func):
def wrapper():
print(surrounding_text)
func()
print(surrounding_text)
return wrapper
return actual_decorator
### use it:
@my_decorator_with_args('***')
def say_hello():
print("Hello!")
say_hello()