This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author andyharrington
Recipients andyharrington
Date 2012-03-30.20:32:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333139530.69.0.0400880123602.issue14454@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-03-30 20:32:10andyharringtonsetrecipients: + andyharrington
2012-03-30 20:32:10andyharringtonsetmessageid: <1333139530.69.0.0400880123602.issue14454@psf.upfronthosting.co.za>
2012-03-30 20:32:10andyharringtonlinkissue14454 messages
2012-03-30 20:32:10andyharringtoncreate