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 Mickaël.Falck, bethard, chris.jerdonek, paul.j3
Date 2013-11-25.17:41:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385401262.6.0.398110470914.issue17204@psf.upfronthosting.co.za>
In-reply-to
Content
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`.
History
Date User Action Args
2013-11-25 17:41:02paul.j3setrecipients: + paul.j3, bethard, chris.jerdonek, Mickaël.Falck
2013-11-25 17:41:02paul.j3setmessageid: <1385401262.6.0.398110470914.issue17204@psf.upfronthosting.co.za>
2013-11-25 17:41:02paul.j3linkissue17204 messages
2013-11-25 17:41:02paul.j3create