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 <[email protected]>
<http://bugs.python.org/issue27153>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com