A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-March/098289.html below:

[Python-Dev] argparse ugliness

[Python-Dev] argparse uglinessDavid Stanek dstanek at dstanek.com
Mon Mar 8 16:53:43 CET 2010
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.add_argument ('--plot', action='store_true')
>
> is equivalent to:
>
>  parser.add_argument('--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.add_argument('--plot', actions.store_true)

Basically a small namespace for the constants.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4