You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
argparse not including '--' arguments in previous optional REMAINDER argument #66419
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2014-08-18.09:46:02.121>labels= ['type-bug', 'library']
title="argparse not including '--' arguments in previous optional REMAINDER argument"updated_at=<Date2014-08-20.13:47:19.982>user='https://bugs.python.org/JurkoGospodneti'
If you have an optional nargs=argparse.REMAINDER argument defined
then, if specified, its value should contain all the remaining command-line content. However, it seems that value does not include later '--' arguments.
REMAINDER is currently undocumented (see bpo-17050/gh-61252), but the proposed change looks right. This would allow to use REMAINDER to simulate a subparser with option as the command (currently the subparser machinery does not support this). I believe it is just an omission that this was not supported before.
Activity
JurkoGospodneti commentedon Aug 18, 2014
If you have an optional nargs=argparse.REMAINDER argument defined
then, if specified, its value should contain all the remaining command-line content. However, it seems that value does not include later '--' arguments.
For example, the following works as expected:
But the following fails with
'PROG: error: unrecognized arguments: -- ZZ':
Note that the same code works as expected when using a
positional nargs=argparse.REMAINDER arguments:
But that, of course, does not allow us to have the args value
start with something like "--blah" that looks like an optional
argument.
Hope this helps.
Best regards,
Jurko Gospodnetić
JurkoGospodneti commentedon Aug 18, 2014
Might be related to the following issues:
http://bugs.python.org/issue9571
http://bugs.python.org/issue13922
serhiy-storchaka commentedon Sep 25, 2024
REMAINDER is currently undocumented (see bpo-17050/gh-61252), but the proposed change looks right. This would allow to use REMAINDER to simulate a subparser with option as the command (currently the subparser machinery does not support this). I believe it is just an omission that this was not supported before.
pythongh-66419: Make optional arguments with nargs=REMAINDER consume …
gh-66419: Make optional arguments with nargs=REMAINDER consume all ar…
pythongh-66419: Make optional arguments with nargs=REMAINDER consume …