Message115017
The argparse module lists required args as optional in the default help message.
If you run the following program (also attached) you'll get the output listed below.
#!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser(
description = 'Do something'
)
parser.add_argument('--reqarg', '-r', help = 'This is required', required = True)
parser.add_argument('--optarg','-o', help = "This is optional", required = False)
args = parser.parse_args()
$ python argparse-help-says-required-args-are-optional.py -h
usage: argparse-help-says-required-args-are-optional.py [-h] --reqarg REQARG
[--optarg OPTARG]
Do something
optional arguments:
-h, --help show this help message and exit
--reqarg REQARG, -r REQARG
This is required
--optarg OPTARG, -o OPTARG
This is optional
$ |
|
Date |
User |
Action |
Args |
2010-08-26 18:19:19 | benschmaus | set | recipients:
+ benschmaus |
2010-08-26 18:19:19 | benschmaus | set | messageid: <1282846759.11.0.900867962743.issue9694@psf.upfronthosting.co.za> |
2010-08-26 18:19:17 | benschmaus | link | issue9694 messages |
2010-08-26 18:19:17 | benschmaus | create | |
|