argh

Python’s argh library: preserve docstring formatting in help message

爱⌒轻易说出口 提交于 2019-12-21 04:25:25
问题 While searching for faster ways to parse command-line arguments in my scripts I came across the argh library. I really like the features of argh but I’ve encountered one drawback that stops me from using it, and this has to do with the default help message that gets displayed if I’m invoking the —help option: per default the function’s docstring is displayed on top of the arguments list. This is great, however the initial formatting is lost. See, for example, the following example script

Python’s argh library: preserve docstring formatting in help message

馋奶兔 提交于 2019-12-03 13:32:56
While searching for faster ways to parse command-line arguments in my scripts I came across the argh library . I really like the features of argh but I’ve encountered one drawback that stops me from using it, and this has to do with the default help message that gets displayed if I’m invoking the —help option: per default the function’s docstring is displayed on top of the arguments list. This is great, however the initial formatting is lost. See, for example, the following example script import argh def func(foo=1, bar=True): """Sample function. Parameters: foo: float An example argument. bar

python argh/argparse: How can I pass a list as a command-line argument?

时光怂恿深爱的人放手 提交于 2019-11-29 20:33:04
I'm trying to pass a list of arguments to a python script using the argh library. Something that can take inputs like these: ./my_script.py my-func --argA blah --argB 1 2 3 4 ./my_script.py my-func --argA blah --argB 1 ./my_script.py my-func --argA blah --argB My internal code looks like this: import argh @argh.arg('--argA', default="bleh", help='My first arg') @argh.arg('--argB', default=[], help='A list-type arg--except it\'s not!') def my_func(args): "A function that does something" print args.argA print args.argB for b in args.argB: print int(b)*int(b) #Print the square of each number in

python argh/argparse: How can I pass a list as a command-line argument?

大城市里の小女人 提交于 2019-11-28 16:34:36
问题 I'm trying to pass a list of arguments to a python script using the argh library. Something that can take inputs like these: ./my_script.py my-func --argA blah --argB 1 2 3 4 ./my_script.py my-func --argA blah --argB 1 ./my_script.py my-func --argA blah --argB My internal code looks like this: import argh @argh.arg('--argA', default="bleh", help='My first arg') @argh.arg('--argB', default=[], help='A list-type arg--except it\'s not!') def my_func(args): "A function that does something" print