Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Required options in optparse

Reply
Thread Tools

Required options in optparse

 
 
Gregory (Grisha) Trubetskoy
Guest
Posts: n/a
 
      10-04-2003

My humble $0.02:

From http://www.python.org/doc/current/li...minology.html:

The phrase "required option" is an oxymoron; the presence of
"required options" in a program is usually a sign of careless user
interface design. optparse doesn't prevent you from implementing
required options, but doesn't give you much help with it either.

I don't know if I necessarily agree with this. While "required option" may
be an oxymoron as far as English is concerned, I think a more accurate
assessment is that "option" is a misnomer, because there is nothing wrong
with requiring one.

Here is an example from a fictional database program. Imagine that to
craete a database I have to specify a name, db size and a some kind of a
device id (the two latter both being integers):

usage: initdb dbname -s size -d dev_id [-t dbtype]

e.g.:

$ initdb mydb -s 1024 -d 1010

Arguably, dbname, size and dev_id could be specified as required
positional _arguments_, but it would be less clear and more error-prone:

usage: initdb dbname size dev_id [-t dbname]

e.g.:

$ initdb mydb 1024 1010

Therefore, I think "required options" should be part of OptionParser.

Anyone disagree?

Grisha
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
optparse options icarus Python 2 05-20-2009 07:54 AM
Re: optparse - required options Omari Norman Python 2 08-24-2007 03:56 AM
getopt or optparse options/arguments wrapping? Rocky Zhou Python 3 03-18-2007 07:45 PM
optparse and counting arguments (not options) Steven Bethard Python 0 05-10-2006 04:33 AM
Re: Iterating over optparse options David Goodger Python 0 06-25-2003 01:46 PM



Advertisments