paul j3 added the comment:

Clint, the problem is the argparse uses different argument allocation method 
than optparse.

optparse gives the '--subscipt_args` Action all of the remaining strings, and 
says - 'consume what you want, and return the rest'.  So you consume up to (and 
including) the '--'.  Then optparse continues with the rest.

argparse performs the double pass described earlier, and allocates strings to 
each Action based on the larger context.  It gives as many as the Action's 
nargs requires, but tries in various ways to reserve strings for other Actions. 
 Individual Actions never see the big picture.

So the 'REMAINDER' action has to be last (with this '--' positional exception). 
 Your users will have to use the other flags Actions first.

One alternative comes to mind:

- omit the final positional
- use parse_known_args instead of parse_args

Then the 'extras' list will be something like:  ['--', '--verbose'], which you 
can handle in another parser.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9334>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to