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.
Created on 2012年03月30日 20:32 by andyharrington, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| metavarListEnhancement.txt | andyharrington, 2012年03月30日 20:32 | line oriented description of metavar enhancement | ||
| Messages (2) | |||
|---|---|---|---|
| msg157148 - (view) | Author: Andy Harrington (andyharrington) | Date: 2012年03月30日 20:32 | |
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.
|
|||
| msg157162 - (view) | Author: Andy Harrington (andyharrington) | Date: 2012年03月31日 01:30 | |
Withdrawn. My error. I missed the part of the documentation that says a *tuple*, not the list that I tried, does just what I wanted. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:28 | admin | set | github: 58659 |
| 2012年03月31日 01:30:50 | andyharrington | set | status: open -> closed assignee: docs@python components: + Documentation, - Library (Lib) nosy: + docs@python messages: + msg157162 resolution: not a bug |
| 2012年03月30日 20:32:10 | andyharrington | create | |