[New-bugs-announce] [issue22500] Argparse always stores True for positional arguments

Tristan Fisher report at bugs.python.org
Fri Sep 26 04:13:11 CEST 2014


New submission from Tristan Fisher:

It's my understanding that giving the action="store_true" to an argument in argparse defaults to False.  When using non-double-dashed/positional arguments, the argument resorts to True (even if explicitly marked default=False).

I've attached a minimal example, but, for clarity, the relevant line is as such:

    parser.add_argument("meow", action="store_true", default=False)


I realize that this might strike some as an odd usage, and I always have the option of using "--meow," but I found it odd that a positional argument is always True, even if not specified in sys.argv.

----------
components: Library (Lib)
files: argparse_always_true.py
messages: 227584
nosy: Tristan.Fisher
priority: normal
severity: normal
status: open
title: Argparse always stores True for positional arguments
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file36727/argparse_always_true.py

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


More information about the New-bugs-announce mailing list