paul j3 added the comment: Look at http://bugs.python.org/issue9338 argparse optionals with nargs='?', '*' or '+' can't be followed by positionals
That has a proposed patch that wraps the main argument consumption loop in another loop. The current loop alternatively consumes optionals and positionals until the argv list is done. The `consume_loop` method in that patch tries various allocations of argv strings between optionals and positionals. It performs 'dry' runs until it finds something that consumes most of the strings, and then does the actual parsing with changes to the namespace. The idea might be adapted to work with subparsers, paying attention, as you do, to the 'extras' from parse_known_args. But it might be hard to reliably perform a 'dry' run when subparsers are involved. I suspect that any change along this line will be too complex to ever be the default behavior. The chances of messing with backward compatibility are just too great. It might pass as an alternative parsing call. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24166> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com