When writing a script, I sometimes use a function to encapsulate exactly what the script does. This is because I might want to call the function from code or run it as a script. Is there any way to avoid repeating the documentation of the function arguments in the help strings in argparse? For example:
import argparse
def my_function(arg_one, arg_two):
"""
arg_one: The first argument.
arg_two: The second argument.
"""
print("The first argument is %r" % arg_one)
print("The second argument is %r" % arg_two)
if __name__=="main":
parser = argparse.ArgumentParser()
parser.add_argument('--arg-one', help="The first argument.")
parser.add_argument('--arg-two', help="The second argument.")
args = parser.parse_args()
my_function(args.arg_one, args.arg_two)
Since the arguments of the function and the script exactly correspond, you can see that I've had to document them twice ("The first argument", "The second argument"). Its a trivial problem, but its really annoying. Should I just not be using a function at all?