merging argparse parsers

Andrea Crotti andrea.crotti.0 at gmail.com
Fri Dec 16 06:37:54 EST 2011


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?



More information about the Python-list mailing list