[issue17050] argparse.REMAINDER doesn't work as first argument

paul j3 report at bugs.python.org
Wed Feb 14 18:35:27 EST 2018


paul j3 <ajipanca at gmail.com> added the comment:

REMAINDER is not widely used, and probably was not tested thoroughly during development. It works for the example given in the docs.  

A variant, argparse.PARSER ('A...') is widely used.  This is, effectively, REMAINDER ('...') that requires an initial non-optional string.  Sort of what '+' is to '*'.

I suspect REMAINDER is most reliable when used as nargs for an optional, e.g.

    add_argument('--rest', nargs=argparse.REMAINDER)

That way it's clear to everyone, developer, user, and the parser that the following strings are to be taken is.  

When parsing the command line, clarity should have priority over convenience.

----------

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


More information about the Python-bugs-list mailing list