[Python-Dev] argparse ugliness (original) (raw)

Neal Becker ndbecker2 at gmail.com
Mon Mar 8 17:44:15 CET 2010


On Monday 08 March 2010, David Stanek wrote:

On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard

<steven.bethard at gmail.com> wrote: > In argparse, unlike optparse, actions are actually defined by objects > with a particular API, and the string is just a shorthand for > referring to that. So: > > parser.addargument ('--plot', action='storetrue') > > is equivalent to: > > parser.addargument('--plot', argparse.StoreTrueAction) > > Because the names are so long and you'd have to import them, I've left > them as private attributes of the module, but if there's really > demand, we could rename them to argparse.StoreTrueAction, etc. Any reason not to do something like: from argparse import actions ... parser.addargument('--plot', actions.storetrue) Basically a small namespace for the constants. +1



More information about the Python-Dev mailing list