[New-bugs-announce] [issue15271] argparse: repeatedly specifying the same argument ignores the previous ones

Ionuț Arțăriși report at bugs.python.org
Sat Jul 7 10:45:41 CEST 2012


New submission from Ionuț Arțăriși <ionut at artarisi.eu>:

To reproduce:

>>> import argparse
[74536 refs]
>>> parser = argparse.ArgumentParser()
[74809 refs]
>>> parser.add_argument("foo")
>>> parser.add_argument("foo")
>>> parser.parse_args(["bar"])

usage: ipython [-h] foo foo
ipython: error: too few arguments
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

>>> parser.parse_args(["bar", "baz"])
>>> Namespace(foo='baz')

So it actually makes you provide two arguments, but it loses/ignores the first one and there's no way to get it back.

----------
messages: 164791
nosy: bethard, mapleoin
priority: normal
severity: normal
status: open
title: argparse: repeatedly specifying the same argument ignores the previous ones
type: behavior

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


More information about the New-bugs-announce mailing list