Message276634
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. |
|
Date |
User |
Action |
Args |
2016-09-15 22:48:34 | paul.j3 | set | recipients:
+ paul.j3, cben, amcnabb, bethard, eric.smith, eric.araujo, r.david.murray, memeplex, gfxmonk, andersk, abacabadabacaba, gdb, nelhage, drm, davidben, martin.panter, skilletaudio, Christophe.Guillon, danielsh, spaceone, Clint Olsen |
2016-09-15 22:48:34 | paul.j3 | set | messageid: <1473979714.67.0.284962975128.issue9334@psf.upfronthosting.co.za> |
2016-09-15 22:48:34 | paul.j3 | link | issue9334 messages |
2016-09-15 22:48:34 | paul.j3 | create | |
|