[getopt-sig] The bake-off

Greg Ward gward@python.net
Thu, 30 May 2002 10:46:18 -0400


On 30 May 2002, A.T. Hofkamp said:
> I have seen a quite large number of (C++/Java/Python) option parsing
> libraries, and all of them just seem to grab a solution from the air,
> implement it, and present it as the solution (Optik does that too).

Actually, Optik did not spring suddenly out of whole cloth.  Ever since
I learned C++ in 1992, and thought I understood OO programming, I
churned out another option-parsing library every couple of years.  First
in C++, then I translated that into C when I decided C++ was stupid,
then Perl when I figured out its object model, then three attempts in
Python (one of which snuck into the standard library as
distutils.fancy_getopt).

Amazingly enough, Optik is the first time in all these years that I
think I got it right.  I think I finally understand OO programming too,
after nearly four years of experience with Python and two major
projects.

> Yet for some reason, getopt is the most commonly used option parsing library.
> 
> Therefore, I concluded, there is something that getopt has, what is missing
> in all the other libraries.

Yes: getopt is in the standard library, and it's documented in the
standard library documentation.  You don't have to go out and download
anything.  I'm convinced that's the main reason people use it.  (It's
also pretty simple to use, if frustrating to scale up.)

        Greg
-- 
Greg Ward - Python bigot                                gward@python.net
http://starship.python.net/~gward/
Paranoia is simply an optimistic outlook on life.