Message245641
| Author |
paul.j3 |
| Recipients |
paul.j3, py.user |
| Date |
2015年06月22日.17:36:05 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1434994565.62.0.404657490798.issue24419@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
To wrap this up, the correct way to specify that 2 or more positionals share a 'dest' is to supply that dest as the first parameter. If the help should have something else, use the `metavar`.
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('x', action='append_const', const=42, metavar='foo')
parser.add_argument('x', action='append_const', const=43, metavar='bar')
parser.print_help()
args=parser.parse_args([])
print(args)
produces
usage: issue24419.py [-h]
positional arguments:
foo
bar
optional arguments:
-h, --help show this help message and exit
Namespace(x=[42, 43])
(I think this issue can be closed). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年06月22日 17:36:05 | paul.j3 | set | recipients:
+ paul.j3, py.user |
| 2015年06月22日 17:36:05 | paul.j3 | set | messageid: <1434994565.62.0.404657490798.issue24419@psf.upfronthosting.co.za> |
| 2015年06月22日 17:36:05 | paul.j3 | link | issue24419 messages |
| 2015年06月22日 17:36:05 | paul.j3 | create |
|