A. Ja.
from functools import wraps
from typing import Any, Callable, TypeVar, cast
FuncType = TypeVar("FuncType", bound=Callable[..., Any])
def print_funcname(func: FuncType) -> FuncType:
@wraps(func)
def wrapper():
print("Funktionsname:", func.__name__)
func()
return cast(FuncType, wrapper)
@print_funcname
def hello():
print("Hello!")
Recommended Posts