Arg decoding with a template?

Hans-Joachim Widmaier hjwidmaier at web.de
Thu Aug 2 01:08:22 EDT 2001


Skip Montanaro <skip at pobox.com> wrote in message news:<mailman.996679503.16815.python-list at python.org>...
> Hans-J> I would have written a parser for this under Unix, but I prefer
> Hans-J> to have a consistent interface, which means basically getopt()
> Hans-J> (though I did write my own C getopt()).
> 
> Ok, I'll bite.  Why write your own C getopt?  There are several floating
> around, and there's the standard module delivered with Python.  Option
> parsing hardly seems like performance-cricial code.

Well, I did this long before I've heard of GNU and even before our
BDFL started working on a new language called "Python." The C library
getopt() just didn't do all I wanted (allow options after arguments
[this is on thing I really dislike about python's getopt -- it doesn't
allow that; even with modern shells, it's a lot easier to just add a
(forgotten) option after the ten filenames you've just written than to
bring your cursor back and add it there], long options, optional
arguments [to options i.e.], options starting with '+'; so it never
was a question of performance -- it was one of features).
I also needed an option parser for MS-DOS, so I had to write one,
anyway. Granted, I probably wouldn't do it again, now, but since its
there and rather convenient, I keep using it. In my python programs, I
stick with the getopt module.

Hans-J.



More information about the Python-list mailing list