I have a function with many arguments and a detailed help message, e.g.:
def worker_function(arg1, arg2, arg3):
""" desired help message:
arg1 - blah
arg2 - foo
arg3 - bar
"""
print arg1, arg2, arg3
I also have a wrapper function which does some accounting and then calls my worker_function, passing all arguments to it as is.
def wrapper_function(**args):
""" this function calls worker_function """
### do something here ...
worker_function(**args)
I want the help message (displayed by python built-in help() function) for wrapper function to have argument list and help message from worker function.
The closest solution I could get is to do:
wrapper_function.__doc__ += "\n\n" + worker_function.__doc__
This results in:
>>? help(wrapper_function)
Help on function wrapper_function in module __main__:
wrapper_function(**args)
this function calls worker function
desired help message:
arg1 - blah
arg2 - foo
arg3 - bar
But this description is missing the essential part - the argument list, that is:
worker_function(arg1, arg2, arg3)
(In real-life function the argument list is long, with telling default values, and I would like that to be displayed automatically).
Is there a way to add an argument list or worker_function to the help message of wrapper_function?