Library for handling GNU parameters

François Pinard pinard at iro.umontreal.ca
Tue Feb 24 14:36:45 CET 2004


[David Goodger]

> Do you mean "optional option arguments"?  Where an option has an
> optional argument?

Within GNU `getopt', it is requested by a double colon after an
option letter in the option string, and with the predefined constant
`optional_argument' in the second position of a `struct option'
entry (the two other predefined constants being `no_argument' and
`required_argument').

> I believe this idea was discussed on the optik-users list, but it was
> determined that such a thing is not reliably parseable.

GNU `getopt' parses it.  Yet, users have to be careful while providing
the optional value, for complying with the rules.  About if this is the
parser, or the user,  not being reliable, is a debatable question :-).

> getopt.py does *not* handle "optional option arguments" either.

I noticed.  When I translated Recode to Python, I had to devise a stunt
around this limitation.

> If you meant optional positional arguments, optparse and getopt both
> support them (by leaving the logic up to the client program).

:-) :-). By leaving the logic up to the client program, every module
could be said to support every thinkable feature!  This is not exactly
what we usually mean by "support"! :-)

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list