Prepending a function docstring with a decorator in python
Question: How would you be able to prepend a functions docstring with a decorator?

    
    
    def g(func):
        someOtherDocString = "That is great"
        def wrap(*args, **kwargs):
            func(*args, **kwargs)
    return wrap
    
    @g
    def f():
    """ This is awesome """
    

result:

    
    
    >>>help(f)
    
    Help on function f in module __main__:
    
    f()
        That is great
        That is awesome
    

All the help would be greatly appreciated.


Answer: Have you tried magic `__doc__`:

    
    
    from functools import wraps
    
    def g(func):
        func.__doc__ = "That is great" + func.__doc__
    
        @wraps(func)
        def wrap(*args, **kwargs):
            return func(*args, **kwargs)
    
        return wrap
    

