This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients paul.j3, tellendil
Date 2015-05-12.22:12:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Look at
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.
Date User Action Args
2015-05-12 22:12:04paul.j3setrecipients: + paul.j3, tellendil
2015-05-12 22:12:04paul.j3setmessageid: <>
2015-05-12 22:12:04paul.j3linkissue24166 messages
2015-05-12 22:12:04paul.j3create