Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104656

argparse

From Fillmore <fillmore_remove@hotmail.com>
Newsgroups comp.lang.python
Subject argparse
Date 2016-03-11 18:18 -0500
Organization Aioe.org NNTP Server
Message-ID <nbvjnl$7v7$1@gioia.aioe.org> (permalink)

Show all headers | View raw


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?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

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

csiph-web