[issue15271] argparse: repeatedly specifying the same argument ignores the previous ones

Steven Bethard report at bugs.python.org
Mon Jul 23 00:37:36 CEST 2012


Steven Bethard <steven.bethard at gmail.com> added the comment:

I don't think this is a bug. You've specified two arguments with the same destination, "foo". This means that argparse will parse the first one, assign it to the attribute "foo" and then parse the second one and assign it to the attribute "foo" again, overwriting the previous one. So you only see the second one, but the first one wasn't ignored.

If you didn't want them to overwrite the same attribute, you either need to declare them as action="append" so that they both add to the same attribute, or you need to declare them with different destinations (and use metavar="foo" if you want them to display the same way).

----------

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


More information about the Python-bugs-list mailing list