paul j3 added the comment: "msg113512 - (view) Author: Steven Bethard (bethard) Seems like there's minimally the bug that argparse should currently throw an error if you add an argument after subparsers (since that argument will never be parsed under the current semantics)."
This isn't quite right. If the main usage signature is: usage: PROG [-h] foo {one,two} ... baz the parser._match_arguments_partial() method will allocate the 1st string to 'foo', the last to 'baz', and pass the rest to the subparser(s). It doesn't know how many the subparsers can use, but it knows that 'baz' requires one. From the standpoint of matching argument strings and arguments, a subparser is essentially a '+' positional. On the other hand if 'baz' (the positional after the subparser) was '*' or '?' it would not get any strings. If it is possible that subparser(s) doesn't need all the strings passed to it, the user could use 'parse_known_args', and deal with the unparsed strings themselves (possibly with another parser). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9253> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com