[New-bugs-announce] [issue17050] argparse.REMAINDER doesn't work as first argument

Chris Jerdonek report at bugs.python.org
Sun Jan 27 09:51:01 CET 2013


New submission from Chris Jerdonek:

Works:

>>> p = ArgumentParser(prog='test.py')
>>> p.add_argument('pos')
>>> p.add_argument('remainder', nargs=argparse.REMAINDER)
>>> p.parse_args(['abc', '--def'])
Namespace(pos='abc', remainder=['--def'])

Doesn't work:

>>> p = ArgumentParser(prog='test.py')
>>> p.add_argument('remainder', nargs=argparse.REMAINDER)
>>> p.parse_args(['--def'])
usage: test.py [-h] ...
test.py: error: unrecognized arguments: --def

This use case comes up, for example, if you would like to extract all the arguments passed to a subparser in order to pass to a different program.

----------
components: Library (Lib)
messages: 180752
nosy: bethard, chris.jerdonek
priority: normal
severity: normal
stage: test needed
status: open
title: argparse.REMAINDER doesn't work as first argument
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4

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


More information about the New-bugs-announce mailing list