473,288 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

Required options in optparse


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
Jul 18 '05 #1
0 1551

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris | last post by:
I'm trying to come up with a not-so-ugly manner of passing many command-line options between modules. I have a Steering.py file, which contains my main() and handles the getopts getting of...
7
by: Henry Ludemann | last post by:
I've been writing an optparse alternative (using getopt) that is at a stage where I'd be interested in people's opinions. It allows you to easily creating command line interfaces to existing...
5
by: Norbert Thek | last post by:
Hi I'm using Python 24 on Windows > (2k) Is there an easy way to convince optparse to accept newline in the helpstring? and more importand also in the 'desc' string. I tried everything (from...
3
by: Karlo Lozovina | last post by:
If I create a file with only one line: --- from optparse import OptionParser --- I get this when I try to run it from "DOS" prompt: Traceback (most recent call last): File "optparse.py",...
7
by: Leo Breebaart | last post by:
I have another question where I am not so much looking for a solution but rather hoping to get some feedback on *which* solutions people here consider good Pythonic ways to approach a issue. ...
0
by: Steven Bethard | last post by:
I feel like I must be reinventing the wheel here, so I figured I'd post to see what other people have been doing for this. In general, I love the optparse interface, but it doesn't do any checks...
8
by: Andrew Robert | last post by:
Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the...
3
by: Rocky Zhou | last post by:
I wonder is there any way to make the wrapper program can wrap options && arguments for the the subprocess/command the wrapper will execute? by getopt or optparse module? This is something...
0
by: Benny the Guard | last post by:
I have become familiar with optparse code to parse various options into a program. But right now having some difficulties with a new project I am working on (not a class project, just a new script)....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.