On Wed, Mar 10, 2010 at 7:46 AM, Nick Coghlan wrote:
> All of this discussion about the class names is ignoring the main
> benefit of using the string names:
Another benefit of strings is that data-driven argparse configuration
will usually be slightly simpler.
Some of us find things like that u
Nick Coghlan wrote:
Greg Ewing wrote:
Steven Bethard wrote:
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.
What's wrong with just StoreTrue?
Greg Ewing wrote:
> Xavier Morel wrote:
>> So you'd have to write add_argument('--plot',
>> action=actions.store_true) which is straight from the department of
>> redundant redundancies.
>
> This could easily be fixed with
>
> from argparse.actions import store_true
Converting argparse from a mo
Greg Ewing wrote:
> Steven Bethard wrote:
>
>> 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.
>
> What's wrong with just StoreTrue?
All of
On Tue, Mar 9, 2010 at 11:31, R. David Murray wrote:
> On Mon, 08 Mar 2010 15:35:46 -0600, Robert Kern wrote:
>> On 2010-03-08 15:20 PM, Greg Ewing wrote:
>> > Mark Russell wrote:
>> >> Boolean flags are a common enough case that I'd be inclined to add a
>> >> wrapper method,
>> >>
>> >> parser.a
On Mon, 08 Mar 2010 15:35:46 -0600, Robert Kern wrote:
> On 2010-03-08 15:20 PM, Greg Ewing wrote:
> > Mark Russell wrote:
> >> Boolean flags are a common enough case that I'd be inclined to add a
> >> wrapper method,
> >>
> >> parser.add_bool_argument('--plot')
> >
> > +1, this looks good.
>
> I
David Stanek writes:
> On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard
> wrote:
> > parser.add_argument ('--plot', action='store_true')
[…]
+1.
> Any reason not to do something like:
>
> from argparse import actions
> ...
> parser.add_argument('--plot', actions.store_true)
>
> Basically
Xavier Morel wrote:
So you'd have to write
add_argument('--plot', action=actions.store_true) which is straight from
the department of redundant redundancies.
This could easily be fixed with
from argparse.actions import store_true
An option would be
parser.add(actions.StoreTrue('--plot'
On 2010-03-08 15:20 PM, Greg Ewing wrote:
Mark Russell wrote:
Boolean flags are a common enough case that I'd be inclined to add a
wrapper method,
parser.add_bool_argument('--plot')
+1, this looks good.
I've added it to the argparse bugtracker, along with my suggested spelling
add_flag():
Steven Bethard wrote:
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.
What's wrong with just StoreTrue?
--
Greg
___
Mark Russell wrote:
Boolean flags are a common enough case that I'd be inclined to add a wrapper
method,
parser.add_bool_argument('--plot')
+1, this looks good.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.or
On Mon, Mar 8, 2010 at 9:17 AM, Ron Adam wrote:
> I like the strings. They are simple and easy to use/read and they don't
> have to be created or imported before the parser is defined.
I like them too. I don't see anything unpythonic about them.
> That allows me
> to put the parser setup right
Steven Bethard wrote:
On Mon, Mar 8, 2010 at 7:40 AM, Steven Bethard wrote:
On Sun, Mar 7, 2010 at 11:49 AM, Guido van Rossum wrote:
On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker wrote:
Brian Curtin wrote:
On Fri, Mar 5, 2010 at 12:51, Neal Becker wrote:
I generally enjoy argparse, but
On Mon, Mar 8, 2010 at 11:49 AM, Xavier Morel wrote:
> On 8 Mar 2010, at 16:53 , David Stanek wrote:
>>
>> On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard
>> wrote:
>>>
>>> In argparse, unlike optparse, actions are actually defined by objects
>>> with a particular API, and the string is just a sh
On 8 Mar 2010, at 16:53 , David Stanek wrote:
>
> On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard
> 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_arg
On Monday 08 March 2010, David Stanek wrote:
> On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard
>
> 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_arg
On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard
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:
>
On Mon, Mar 8, 2010 at 7:40 AM, Steven Bethard wrote:
> On Sun, Mar 7, 2010 at 11:49 AM, Guido van Rossum wrote:
>> On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker wrote:
>>> Brian Curtin wrote:
>>>
On Fri, Mar 5, 2010 at 12:51, Neal Becker wrote:
> I generally enjoy argparse, but one
On Sun, Mar 7, 2010 at 11:49 AM, Guido van Rossum wrote:
> On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker wrote:
>> Brian Curtin wrote:
>>
>>> On Fri, Mar 5, 2010 at 12:51, Neal Becker wrote:
>>>
I generally enjoy argparse, but one thing I find rather
ugly and unpythonic.
par
On 7 Mar 2010, at 19:49, Guido van Rossum wrote:
> How would you write the example instead then?
Boolean flags are a common enough case that I'd be inclined to add a wrapper
method, so you could just say:
parser.add_bool_argument('--plot')
As you can always fall back to the more general
On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker wrote:
> Brian Curtin wrote:
>
>> On Fri, Mar 5, 2010 at 12:51, Neal Becker wrote:
>>
>>> I generally enjoy argparse, but one thing I find rather
>>> ugly and unpythonic.
>>>
>>> parser.add_argument ('--plot', action='store_true')
>>>
>>> Specifying
Brian Curtin wrote:
> On Fri, Mar 5, 2010 at 12:51, Neal Becker 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.
>>
>
> What el
Am 06.03.2010 03:28, schrieb Antoine Pitrou:
> Le Fri, 05 Mar 2010 13:51:15 -0500,
> Neal Becker a écrit :
>> I generally enjoy argparse, but one thing I find rather
>> ugly and unpythonic.
>>
>> parser.add_argument ('--plot', action='store_true')
>
> I would argue that a string is actually
Antoine Pitrou wrote:
I would argue that a string is actually more Pythonic than
integers or anonymous objects repurposed as magic constants.
(I'm looking at things such as SEEK_SET and friends)
Strings are certainly preferable to ints, one reason being that
they display as something meaningfu
I don't believe argparse's action specification scheme is bad either, but
On 6 Mar 2010, at 13:50 , Nick Coghlan wrote:
>
> you wouldn't get the static name checking that is
> the primary benefit of using named constants in less dynamic languages.
There are quite a few tools which do handle stat
Neal Becker 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.
It isn't ideal, but having to grab constants from the module isn't ideal
e
Le Fri, 05 Mar 2010 13:51:15 -0500,
Neal Becker a écrit :
> I generally enjoy argparse, but one thing I find rather
> ugly and unpythonic.
>
> parser.add_argument ('--plot', action='store_true')
I would argue that a string is actually more Pythonic than
integers or anonymous objects repurpos
On Fri, Mar 5, 2010 at 10:51 AM, Neal Becker 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:
On Fri, Mar 5, 2010 at 12:51, Neal Becker 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.
>
What else would you propose?
FWIW, this is
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.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail
30 matches
Mail list logo