[issue14454] argparse metavar list parameter with nargs=k
Andy Harrington
report at bugs.python.org
Fri Mar 30 22:32:10 CEST 2012
New submission from Andy Harrington <aharrin at luc.edu>:
I now set the help string for an
argparse option with two parameters:
parser.add_argument('-s', '--substitute', nargs=2,
help='Replace first string with second',
metavar='string')
which generates a help message
-s string string, --substitute string string
Replace first string with second
Instead I would *like* to generate the help message
-s fromString toString, --substitute fromString toString
Replace fromString with toString
At present metavar replaces each of multiple parameters with the same thing,
but with a fixed number of parameters it makes sense that each may have a
different meaning.
It seems to me that when nargs=k is set for an integer k,
we could have metavar be a list of k strings to go in the k places,
as in
parser.add_argument('-s', '--substitute', nargs=2,
help='Replace fromString with toString',
metavar=['fromString', 'toString'])
and have this generate my desired help message.
There is no need to break the current behavior:
The parser can distinguish a list from a single string.
The same text is in the attached file.
----------
components: Library (Lib)
files: metavarListEnhancement.txt
messages: 157148
nosy: andyharrington
priority: normal
severity: normal
status: open
title: argparse metavar list parameter with nargs=k
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file25074/metavarListEnhancement.txt
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14454>
_______________________________________
More information about the Python-bugs-list
mailing list