Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104656 > unrolled thread
| Started by | Fillmore <fillmore_remove@hotmail.com> |
|---|---|
| First post | 2016-03-11 18:18 -0500 |
| Last post | 2016-03-12 13:21 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
argparse Fillmore <fillmore_remove@hotmail.com> - 2016-03-11 18:18 -0500
Re: argparse Fillmore <fillmore_remove@hotmail.com> - 2016-03-11 18:32 -0500
Re: argparse "Sven R. Kunze" <srkunze@mail.de> - 2016-03-12 13:21 +0100
| From | Fillmore <fillmore_remove@hotmail.com> |
|---|---|
| Date | 2016-03-11 18:18 -0500 |
| Subject | argparse |
| Message-ID | <nbvjnl$7v7$1@gioia.aioe.org> |
Playing with ArgumentParser. I can't find a way to override the -h and
--help options so that it provides my custom help message.
-h, --help show this help message and exit
Here is what I am trying:
parser = argparse.ArgumentParser("csresolver.py",add_help=False)
parser.add_argument("-h","--help",
help="USAGE: <STDIN> | myscript.py [-exf Exception
File]")
parser.add_argument("-e","--ext", type=str,
help="Exception file")
args = parser.parse_args()
The result:
$ ./myscript.py -h
usage: myscript.py [-h HELP] [-e EXT]
csresolver.py: error: argument -h/--help: expected one argument
am I missing something obvious?
[toc] | [next] | [standalone]
| From | Fillmore <fillmore_remove@hotmail.com> |
|---|---|
| Date | 2016-03-11 18:32 -0500 |
| Message-ID | <nbvkjc$8nk$1@gioia.aioe.org> |
| In reply to | #104656 |
On 3/11/2016 6:26 PM, Larry Martell wrote: >> am I missing something obvious? > > https://docs.python.org/2/library/argparse.html#usage you rock!
[toc] | [prev] | [next] | [standalone]
| From | "Sven R. Kunze" <srkunze@mail.de> |
|---|---|
| Date | 2016-03-12 13:21 +0100 |
| Message-ID | <mailman.36.1457785295.12893.python-list@python.org> |
| In reply to | #104656 |
On 12.03.2016 00:18, Fillmore wrote: > > Playing with ArgumentParser. I can't find a way to override the -h and > --help options so that it provides my custom help message. I remember everything being a lot easier using argh instead of argparse. https://pypi.python.org/pypi/argh#examples The doc string of a function basically is the help string which is true for arguments as well. I hope that helps even though you asked for argparse explicitly. :-) Best, Sven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web