[New-bugs-announce] [issue16399] argparse:
Markus Amalthea Magnuson
report at bugs.python.org
Sun Nov 4 02:30:23 CET 2012
New submission from Markus Amalthea Magnuson:
If the default value for a flag is a list, and the action append is used, argparse doesn't seem to override the default, but instead adding to it. I did this test script:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'--foo',
action='append',
default=['bar1', 'bar2']
)
args = parser.parse_args()
print args.foo
Output is as follows:
$ ./argparse_foo_test.py
['bar1', 'bar2']
$ ./argparse_foo_test.py --foo bar3
['bar1', 'bar2', 'bar3']
I would expect the last output to be ['bar3'].
Is this on purpose (although very confusing) or is it a bug?
----------
components: Library (Lib)
files: argparse_foo_test.py
messages: 174735
nosy: Markus.Amalthea.Magnuson
priority: normal
severity: normal
status: open
title: argparse:
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file27874/argparse_foo_test.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16399>
_______________________________________
More information about the New-bugs-announce
mailing list