Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17352

merging argparse parsers

Date 2011-12-16 11:37 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject merging argparse parsers
Newsgroups comp.lang.python
Message-ID <mailman.3724.1324035481.27778.python-list@python.org> (permalink)

Show all headers | View raw


I would like to have something like

merged_parser = LoggingParser() + OtherParser()

Which should create an argument parser with all the options composed.

Now for that I think I would need to subclass the argument, and something
fancy with the overloading.
The problem is that apparently there is no Argument class, but add_argument
just change the object internal data structures.

So the only alternative I see now is to do something like:
def add_project_argument(parser):
     parser.add_argument('project_path',
                         help='paths of the project to run')

which is not very neat and modifies the object in place.
Any other ideas?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

merging argparse parsers Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-16 11:37 +0000

csiph-web