Search code examples
pythonpython-3.xdecorator

Decorator hide method description


When I put a class method under a decorator it hides the method description ("""x""") in help(class_name). How can I fix that please ?


Solution

  • Using functools.wraps:

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