getopt: Make argument mandatory

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed Dec 15 22:05:33 CET 2004


In <mailman.7809.1103142453.5135.python-list at python.org>, Frans Englich
wrote:

>> > In my use of getopt.getopt, I would like to make a certain parameter
>> > mandatory.
>>
>> Isn't a *mandatory option* a contradiction?  Why don't you turn it into an
>> argument?  You already called it argument in the subject of your post.
> 
> I probably used an inconsisten wording; option equals argument. My point is to 
> make an option/parameter/argument/call-it-what-you-like mandatory. When that 
> particular option/argument then also has a value(instead of a simple toggle), 
> that means a user specified value must always be specified.

I had the following in mind:

  http://www.python.org/doc/2.4/lib/optparse-what-options-for.html

Although the optparse documentation discourages `required options` there
are two examples in the source distribution how to implement them with the
optparse module.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list