编程语言
首页 > 编程语言> > python wraps装饰器

python wraps装饰器

作者:互联网

from functools import wraps


def decorator(func):
    """this is decorator __doc__"""

    @wraps(func)
    def wrapper(*args, **kwargs):
        """this is wrapper __doc__"""
        print("this is wrapper method")
        return func(*args, **kwargs)
    return wrapper

@decorator
def test():
    """this is test __doc__"""
    print("this is test method")

print("__name__: ", test.__name__)
print("__doc__:  ", test.__doc__)

标签:__,wraps,python,doc,wrapper,print,test,装饰
来源: https://www.cnblogs.com/Higgerw/p/16609627.html