On Thu, Jun 9, 2011 at 9:28 AM, Hyrum K Wright <hy...@hyrumwright.org> wrote: > On Wed, Jun 8, 2011 at 5:59 AM, anatoly techtonik <techto...@gmail.com> wrote: >> On Wed, Jun 8, 2011 at 12:57 PM, Stefan Sperling <s...@elego.de> wrote: >>> On Wed, Jun 08, 2011 at 09:34:05AM +0300, anatoly techtonik wrote: >>>> On Mon, Jun 6, 2011 at 6:32 PM, Stefan Sperling <s...@elego.de> wrote: >>>> > On Thu, Jun 02, 2011 at 07:06:05PM +0300, anatoly techtonik wrote: >>>> >> Attached patch fixes svnmerge history conversion script to use >>>> >> optparse library instead of getopt. This allows further addition of >>>> >> new options, such as --username and --password. >>>> > >>>> > Hi, >>>> > >>>> > Can you explain why you need to convert this script to optparse >>>> > to add new options? Is this a cosmetic fix or is there a technical >>>> > problem with adding more options via getopt? Thanks! >>>> >>>> 1. It makes code more clear >>>> 2. It saves me time on learning what a getopt is >>> >>> So those who already know getopt should learn about optparse for >>> your convenience? I don't think that's a good argument. >>> By the same argument you could send a patch that rewrites the script >>> in your favourite programming language because you don't like Python. >> >> optparse is de-facto standard for option parsing in Python. It makes >> code more maintainable and clear as you may see from the patch. You >> should waste 15 minutes to play with it if you program Python for >> terminal scripts as it will really save you a lot of time in future. > > Actually, optparse is deprecated as of Python 2.7 in favor of argparse. > > Not that I don't like optparse, mind you, but claiming it as a de > facto standard when it is deprecated is a bit of hyperbole. > > My own personal opinion is that we should standardize our Python > scripts around a particular argument parsing module. If the majority > of our stuff is already using optparse, I see no reason not to allow > an enthusiastic volunteer the ability to convert existing scripts to > it. > > Another option is just following the Python deprecation guidelines, > and moving to argparse throughout, but that would require bumping > everything to Python 2.7, and I don't want to have that bikeshed > today. :)
I thought that argparse is solely Python 3 feature, but it appears it is not. Anyway, it is a logical continuation of optparse, and uses the same way of adding arguments. It is just more powerful with subcommands. http://stackoverflow.com/questions/3217673/why-use-argparse-rather-than-optparse Some coding standard for Python scripts would be nice, because svnmerge scripts are difficult to compare because of whitespaces and different imports from svn. -- anatoly t.