Well, I don't know what is wrong with people then. I don't see how required arguments are of bad design. Some command-line applications are built around performing tasks based on information received. Compilers, for example. A compiler can't do much of anything unless you give it at the very least a filename. So, a --file command would most definitely be one required argument. Anyway, I'm not trying to start a debate on this issue. I have my own implementation for required arguments at the moment, I am just a little bit surprised that this module doesn't make it convenient. It would definitely help on code duplication.
Thanks for your response. On 8/20/07, Jay Loden <[EMAIL PROTECTED]> wrote: > > Robert Dailey wrote: > > Hi, > > > > I've been reading through the python documentation on the optparse > > module and I was unable to find out how to specify if an option is > > optional or required. The documentation vaguely states that actions can > > be used to do this, however I was not able to figure out how. If anyone > > could help I'd greatly appreciate it. > > > > According to the optparse docs: > > required option > an option that must be supplied on the command-line; note that the > phrase ``required option'' is self-contradictory in English. optparse > doesn't prevent you from implementing required options, but doesn't > give you much help at it either. See examples/required_1.py and > examples/required_2.py in the optparse source distribution for two > ways to implement required options with optparse. > > > And from what I can see, this seems to be somewhat intentional, see > http://wiki.python.org/moin/OptParse the note at the bottom with a link to > a mailing list thread. As far as I can tell, evidently some people feel that > required options are indicative of a bad design and therefore optparse was > designed not to make this easy on the programmer. > > -Jay >
-- http://mail.python.org/mailman/listinfo/python-list