R. Oui.
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("Nom de la fonction:", func.__name__)
func()
return cast(FuncType, wrapper)
@print_funcname
def hello():
print("Hello!")
Recommended Posts