Re: [Python-Dev] argparse ugliness

2010-03-10 Thread Nick Coghlan
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 this

Re: [Python-Dev] argparse ugliness

2010-03-10 Thread Nick Coghlan
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 module to a

Re: [Python-Dev] argparse ugliness

2010-03-10 Thread Eric Smith
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?

Re: [Python-Dev] argparse ugliness

2010-03-10 Thread Fred Drake
On Wed, Mar 10, 2010 at 7:46 AM, Nick Coghlan ncogh...@gmail.com 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

Re: [Python-Dev] argparse ugliness

2010-03-09 Thread R. David Murray
On Mon, 08 Mar 2010 15:35:46 -0600, Robert Kern robert.k...@gmail.com 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.

Re: [Python-Dev] argparse ugliness

2010-03-09 Thread Robert Kern
On Tue, Mar 9, 2010 at 11:31, R. David Murray rdmur...@bitdance.com wrote: On Mon, 08 Mar 2010 15:35:46 -0600, Robert Kern robert.k...@gmail.com 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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Mark Russell
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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Steven Bethard
On Sun, Mar 7, 2010 at 11:49 AM, Guido van Rossum gu...@python.org wrote: On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker ndbeck...@gmail.com wrote: Brian Curtin wrote: On Fri, Mar 5, 2010 at 12:51, Neal Becker ndbeck...@gmail.com wrote: I generally enjoy argparse, but one thing I find rather

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Steven Bethard
On Mon, Mar 8, 2010 at 7:40 AM, Steven Bethard steven.beth...@gmail.com wrote: On Sun, Mar 7, 2010 at 11:49 AM, Guido van Rossum gu...@python.org wrote: On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker ndbeck...@gmail.com wrote: Brian Curtin wrote: On Fri, Mar 5, 2010 at 12:51, Neal Becker

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread David Stanek
On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard steven.beth...@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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Neal Becker
On Monday 08 March 2010, David Stanek wrote: On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard steven.beth...@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:

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Xavier Morel
On 8 Mar 2010, at 16:53 , David Stanek wrote: On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard steven.beth...@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:

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread David Stanek
On Mon, Mar 8, 2010 at 11:49 AM, Xavier Morel python-...@masklinn.net wrote: On 8 Mar 2010, at 16:53 , David Stanek wrote: On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard steven.beth...@gmail.com wrote: In argparse, unlike optparse, actions are actually defined by objects with a particular

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Ron Adam
Steven Bethard wrote: On Mon, Mar 8, 2010 at 7:40 AM, Steven Bethard steven.beth...@gmail.com wrote: On Sun, Mar 7, 2010 at 11:49 AM, Guido van Rossum gu...@python.org wrote: On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker ndbeck...@gmail.com wrote: Brian Curtin wrote: On Fri, Mar 5, 2010 at

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Guido van Rossum
On Mon, Mar 8, 2010 at 9:17 AM, Ron Adam r...@ronadam.com 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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Greg Ewing
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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Greg Ewing
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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Robert Kern
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():

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Greg Ewing
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

Re: [Python-Dev] argparse ugliness

2010-03-08 Thread Ben Finney
David Stanek dsta...@dstanek.com writes: On Mon, Mar 8, 2010 at 10:40 AM, Steven Bethard steven.beth...@gmail.com wrote:  parser.add_argument ('--plot', action='store_true') […] +1. Any reason not to do something like: from argparse import actions ...

Re: [Python-Dev] argparse ugliness

2010-03-07 Thread Georg Brandl
Am 06.03.2010 03:28, schrieb Antoine Pitrou: Le Fri, 05 Mar 2010 13:51:15 -0500, Neal Becker ndbeck...@gmail.com 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

Re: [Python-Dev] argparse ugliness

2010-03-07 Thread Guido van Rossum
On Sun, Mar 7, 2010 at 4:29 AM, Neal Becker ndbeck...@gmail.com wrote: Brian Curtin wrote: On Fri, Mar 5, 2010 at 12:51, Neal Becker ndbeck...@gmail.com wrote: I generally enjoy argparse, but one thing I find rather ugly and unpythonic.    parser.add_argument ('--plot',

Re: [Python-Dev] argparse ugliness

2010-03-06 Thread Xavier Morel
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 static

Re: [Python-Dev] argparse ugliness

2010-03-06 Thread Greg Ewing
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

Re: [Python-Dev] argparse ugliness

2010-03-05 Thread Brian Curtin
On Fri, Mar 5, 2010 at 12:51, Neal Becker ndbeck...@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. What else would you propose?

Re: [Python-Dev] argparse ugliness

2010-03-05 Thread Steven Bethard
On Fri, Mar 5, 2010 at 10:51 AM, Neal Becker ndbeck...@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

Re: [Python-Dev] argparse ugliness

2010-03-05 Thread Antoine Pitrou
Le Fri, 05 Mar 2010 13:51:15 -0500, Neal Becker ndbeck...@gmail.com 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