【问题标题】:Decorator hide method description [duplicate]装饰器隐藏方法说明[重复]
【发布时间】:2018-09-29 05:27:29
【问题描述】:

当我将类方法放在装饰器下时,它会在帮助(class_name)中隐藏方法描述(“”“x”“”)。 请问我该如何解决?

【问题讨论】:

    标签: python python-3.x decorator


    【解决方案1】:

    使用functools.wraps

    def decorator(f):
        @functools.wrap(f)
        def wrapped(*args):
            # do something
        return wrapped
    

    【讨论】:

    • 不错,没听说过这个!
    猜你喜欢
    • 2012-02-09
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 2017-07-28
    • 2020-12-03
    • 2017-12-06
    • 2014-07-19
    相关资源
    最近更新 更多