Author paul.j3
Recipients Christophe.Guillon, Clint Olsen, abacabadabacaba, amcnabb, andersk, bethard, cben, danielsh, davidben, drm, eric.araujo, eric.smith, gdb, gfxmonk, martin.panter, memeplex, nelhage, paul.j3, r.david.murray, skilletaudio, spaceone
Date 2016-09-15.02:30:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473906630.8.0.508712730998.issue9334@psf.upfronthosting.co.za>
In-reply-to
Content
Clint, 'nargs=argparser.REMAINDER' ('...') may do what you want

    p=argparse.ArgumentParser()
    p.add_argument('--subscipt_args', nargs='...')
    p.add_argument('pos',nargs='*')

    p.parse_args('--subscipt_args --foo --bar --baz -- other args'.split())

produces

    Namespace(pos=['other', 'args'], subscipt_args=['--foo', '--bar', '--baz'])

'REMAINDER' is like '*' except it takes everything.  But the '--' means 'everything that follows is a positional argument, so it effectively ends the 'REMAINDER'.  'REMAINDER' is documented (briefly), but I don't recall reading about its interaction with '--'.  I'm a little surprised that it wasn't mentioned earlier in this bug/issue.

'+...', argparse.PARSER is similar except it requires at least one argument.  It is used by the 'subparsers' argument, to collect the cmd string and use all that follow as subparser arguments.

There is a bug issue (or two) about what should happen when there are more than one '--' argument.
History
Date User Action Args
2016-09-15 02:30:30paul.j3setrecipients: + 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 02:30:30paul.j3setmessageid: <1473906630.8.0.508712730998.issue9334@psf.upfronthosting.co.za>
2016-09-15 02:30:30paul.j3linkissue9334 messages
2016-09-15 02:30:30paul.j3create