[New-bugs-announce] [issue27153] Default value shown by argparse.ArgumentDefaultsHelpFormatter is backwards for action='store_false'
Colin Morris
report at bugs.python.org
Sun May 29 12:39:34 EDT 2016
New submission from Colin Morris:
Small example:
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--no-foo', dest='foo', action='store_false', help="Suppress foo")
args = parser.parse_args()
print('foo = {}'.format(args.foo))
Output with "-h":
optional arguments:
-h, --help show this help message and exit
--no-foo Suppress foo (default: True)
A reasonable person reading that would think that we suppress foo by default. But actually, foo is True by default - "--no-foo" is off by default. I would suggest that if action='store_false', the default value reported by the formatter should be flipped.
----------
components: Library (Lib)
messages: 266602
nosy: Colin Morris
priority: normal
severity: normal
status: open
title: Default value shown by argparse.ArgumentDefaultsHelpFormatter is backwards for action='store_false'
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27153>
_______________________________________
More information about the New-bugs-announce
mailing list