[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] svnmerge-migrate-history-remotely.py: move from getopt to optparse

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta_at_gmail.com>
Date: Thu, 9 Jun 2011 21:06:53 +0200

2011-06-09 08:28:10 Hyrum K Wright napisaƂ(a):
> On Wed, Jun 8, 2011 at 5:59 AM, anatoly techtonik <techtonik_at_gmail.com> wrote:
> > On Wed, Jun 8, 2011 at 12:57 PM, Stefan Sperling <stsp_at_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 <stsp_at_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. :)

argparse is also externally provided for older versions of Python:
http://pypi.python.org/pypi/argparse
http://code.google.com/p/argparse/

-- 
Arfrever Frehtes Taifersar Arahesis

Received on 2011-06-09 21:07:15 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.