optional args for getopt()
Richard Jones
richard at bizarsoftware.com.au
Thu Aug 23 20:32:02 EDT 2001
On Friday 24 August 2001 09:48, bvdpoel at uniserve.com wrote:
> Richard Jones wrote:
> > On Thursday 23 August 2001 12:59, bvdpoel at uniserve.com wrote:
> > > Is there a way to signal that the arg for getopt in optional. In C I
> > > can set an option string to something like:
> >
> > Sorry, to answer this question directly - I don't believe it's possible
> > in the current getopt code. Your best bet would possibly be to locally
> > change getopt to do qhat you need (and at the same time, generate a patch
> > that can be submitted to python.sf.net).
> >
> > Richard
>
> Thanks. I really was hoping NOT to have to reinvent the wheel. For now
> I'll just leave well enough alone and do my own parsing.... but if any
> maintainers are reading this, it would be nice to have GNU compatibility
> in this.
I wasn't talking about re-inventing the wheel... I was talking about a minor
change to an existing one. OK, attached is a simple patch against the getopt
module from the 2.1 distribution (encoded so mail systems don't mess with the
formatting). I've submitted this to the sourceforge patch repository.
BTW: in a large number of cases in the python library - we, the python
community, are the "maintainers" of the code. Modules get extended when
someone has a need and submits the code the python maintainers.
Note: I've only implemented this behaviour - none of the other GNU
extensions. Hope it's useful for you.
Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getopt.py.diff
Type: text/x-diff
Size: 2227 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20010824/76e875d8/attachment.diff>
More information about the Python-list
mailing list