[Python-Dev] argparse ugliness

Steven Bethard steven.bethard at gmail.com
Sat Mar 6 02:37:15 CET 2010


On Fri, Mar 5, 2010 at 10:51 AM, Neal Becker <ndbecker2 at gmail.com> wrote:
> I generally enjoy argparse, but one thing I find rather
> ugly and unpythonic.
>
>    parser.add_argument ('--plot', action='store_true')
>
> Specifying the argument 'action' as a string is IMO ugly.

If it really bothers you, you can use:

    action=argparse._StoreTrueAction

instead. Undocumented (purposefully) but that's all argparse is doing
under the covers.

Steve
-- 
Where did you get that preposterous hypothesis?
Did Steve tell you that?
        --- The Hiphopopotamus


More information about the Python-Dev mailing list