[New-bugs-announce] [issue15336] Argparse required arguments incorrectly displayed as optional arguments

Raymond Hettinger report at bugs.python.org
Thu Jul 12 21:43:34 CEST 2012


New submission from Raymond Hettinger <raymond.hettinger at gmail.com>:

In this script, '-x' is required argument:
------------------------------------------
import argparse
p = argparse.ArgumentParser()
p.add_argument('-x', required=True)
p.print_help()

However, the automatically generated help shows it as optional:
---------------------------------------------------------------
usage: ap_demo.py [-h] -x X

optional arguments:
  -h, --help  show this help message and exit
  -x X

----------
components: Library (Lib)
messages: 165331
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Argparse required arguments incorrectly displayed as optional arguments
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15336>
_______________________________________


More information about the New-bugs-announce mailing list