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 <rep...@bugs.python.org> <http://bugs.python.org/issue16399> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com