python - argparse's "required" ignored in the help screen? -
consider following code:
import argparse parser = argparse.argumentparser() parser.add_argument('-o', required=true, nargs=1) parser.parse_args(['-h']) why getting following output if said -o required?
usage: test.py [-h] -o o optional arguments: -h, --help show message , exit -o o i expect text -o required.
this issue #9694 on python bug tracker, yet unfixed. can read more there. note usage line correctly indicate switch required (if weren't, usage line read usage: test.py [-h] [-o o] instead of usage: test.py [-h] -o o).
for working around it, can use argument groups can given title. example shows @ linked page, allows create groups choice of name instead of default positional arguments , optional arguments groupings.
Comments
Post a Comment