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 bethard, emcd, paul.j3
Date 2015-03-22.04:08:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426997282.38.0.53960958672.issue23159@psf.upfronthosting.co.za>
In-reply-to
Content
The attached file subclasses ArgumentParser, explores how these optparse methods might be added to argparse.  The __name__ section demonstrates how they might be used.

argparse differs from optparse in a number of ways:

- all actions are included in the parser._actions list.

- the parser has one dictionary with all option_strings (both short and long)

- argparse also has positionals, which don't have option_strings.  They could be found by 'dest' (or some other attribute), but this does not have to be unique.

- argparse does not use argument groups for parsing; just for formatting the help.

- groups keep a list of their own actions in ._group_actions list.  The ._actions list is shared among the parser and all groups.

- every action is in an argument group, usually one of the 2 default groups.  An action does not have a 'container' attribute.

-------------------

The idea of coordinating config sections with parser argument groups is interesting, but I question whether the stock argparser should be modified to facilitate this.  It sounds like something that belongs in a custom subclass.

Ipython populates its argparse parser with arguments derived from config files.  This provides multiple config levels - default, custom file, and calling arguments.  I don't recall whether it makes any use of argument groups.
History
Date User Action Args
2015-03-22 04:08:02paul.j3setrecipients: + paul.j3, bethard, emcd
2015-03-22 04:08:02paul.j3setmessageid: <1426997282.38.0.53960958672.issue23159@psf.upfronthosting.co.za>
2015-03-22 04:08:02paul.j3linkissue23159 messages
2015-03-22 04:08:01paul.j3create