Suggestion: UnixOptionParser class in optparse.py

Bjorn Pettersen BPettersen at NAREX.com
Mon Jan 6 13:45:19 EST 2003


> From: Rich Harkins [mailto:rharkins at thinkronize.com] 
> 
> On Mon, 2003-01-06 at 13:19, Bjorn Pettersen wrote:
> > > From: Rich Harkins [mailto:rharkins at thinkronize.com]
> > > 
> > > I love the OptionParser class.  Good stuff.  The only thing
> > > that I would want different (right now anyway) would be a 
> > > simple way to parse Unix style options (first non-option 
> > > argument terminates options).
> > 
> > Does the getopt module
> > (http://www.python.org/doc/current/lib/module-getopt.html) 
> do what you 
> > want? (It's the pre Python 2.3 way of doing options...)
> > 
> > -- bjorn
> 
> In many ways yes, and I have used it extensively over the 
> years.  OTOH, I have always wanted a class to shorten the 
> standard chunk of code necessary to manage the parsed 
> options, print help, etc., which optparse.py seems to handle 
> quite well -- except for the un-Unix-like ability to stick 
> arguments anywhere in the sys.argv.  Since the author of 
> optparse.py has done a nice job of allowing Unix-like parsing 
> as well, I would simply like to see a subclass that lets me 
> get there without having to subclass it in my own libraries 
> (which will obviously duplicate other's efforts to do the 
> same almost certainly) or stick the exception in the code 
> every time I want to use OptionParser.

Ah, I see. I'm sure a patch will be graciously accepted :-)

-- bjorn





More information about the Python-list mailing list