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


Groups > comp.lang.python > #17352 > unrolled thread

merging argparse parsers

Started byAndrea Crotti <andrea.crotti.0@gmail.com>
First post2011-12-16 11:37 +0000
Last post2011-12-16 11:37 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#17352 — merging argparse parsers

FromAndrea Crotti <andrea.crotti.0@gmail.com>
Date2011-12-16 11:37 +0000
Subjectmerging argparse parsers
Message-ID<mailman.3724.1324035481.27778.python-list@python.org>
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?

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web