Author paul.j3
Recipients bethard, chris.jerdonek, paul.j3
Date 2013-04-17.16:34:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The problem isn't with REMAINDER, but with the distinction between optionals and arguments.  If you change '--def' to 'def', the parse should work:

>>> p = ArgumentParser(prog='')
>>> p.add_argument('remainder', nargs=argparse.REMAINDER)
>>> p.parse_args(['def'])

'--def' would give problems with almost all of the nargs options, especially '*' and '?'.

The issue is that '--def' looks like an optional.  Since it is not found in the defined arguments, it is classed as an unknown extra and skipped (try p.parse_known_args(['--def'])).  All of this takes place before 'REMAINDER' has a chance to look at the argument strings.

In   I submitted a patch that defines a 'args_default_to_positional' parser option.  If this is True, that unrecognized '--def' would be classed as a 'positional' and would be captured by the REMAINDER.
Date User Action Args
2013-04-17 16:34:46paul.j3setrecipients: + paul.j3, bethard, chris.jerdonek
2013-04-17 16:34:46paul.j3setmessageid: <>
2013-04-17 16:34:46paul.j3linkissue17050 messages
2013-04-17 16:34:46paul.j3create