Message204372
http://stackoverflow.com/a/20167038/901925
is an example of using `_parser_class` to produce different behavior in the subparsers.
parser = ArgumentParser()
parser.add_argument('foo')
sp = parser.add_subparsers(dest='cmd')
sp._parser_class = SubParser # use different parser class for subparsers
spp1 = sp.add_parser('cmd1')
spp1.add_argument('-x')
spp1.add_argument('bar')
spp1.add_argument('vars',nargs='*')
In this case the SubParser class implements a `parse_intermixed_known_args` method that handles that `nargs='*'` argument.
http://bugs.python.org/issue14191
It shouldn't be hard to add `parser_class` as a documented optional argument to `add_subparsers`. |
|
Date |
User |
Action |
Args |
2013-11-25 17:41:02 | paul.j3 | set | recipients:
+ paul.j3, bethard, chris.jerdonek, Mickaël.Falck |
2013-11-25 17:41:02 | paul.j3 | set | messageid: <1385401262.6.0.398110470914.issue17204@psf.upfronthosting.co.za> |
2013-11-25 17:41:02 | paul.j3 | link | issue17204 messages |
2013-11-25 17:41:02 | paul.j3 | create | |
|