[getopt-sig] Random thoughts
Greg Ward
gward@python.net
Fri, 15 Feb 2002 14:09:53 -0500
On 15 February 2002, dittmar@snafu.de said:
> Thought 2
>
> Would the following be a violation of
> "explicit is better than implicit" or an application of
> "don't repeat yourself"?
> Optik:
> the default for "dest" is the value of the
> long option without '--'
Someone else already suggested that, and I'm open to it. I just peeked
at the code and it should be easy to slip in.
> the default for "type" is deduced from the type of the "default" value
No, that's too sneaky and implicit. I don't like it.
However, I am thinking of making the default type "string" -- ie. if
Optik expected a type (action="store" or action="append" or dest
supplied), and you didn't give one, it assumes type="string". That's
also implicit behaviour, so potentially unPythonic. But it's awfully
convenient, since most options are string options. Opinions?
> Thought 3
>
> Should there be support for more sources of arguments?
> * @filename in argument list => will expand contents of
> filename into argument list
No. If you want this, implement an OptionParser subclass. If that's
painful, let me know how OptionParser needs to be refactored.
> * Optik (env = varname) will prepend additional options from
> os.environ.get (varname, ''), it's the name of a
> environment variable and not a string because
> that name should be generated into the documentation
Maaaaybe, but I'm cool to it. Same advice as above.
Basically, I want to stop adding features to Optik. If you want a
feature, implement it by subclassing. If subclassing is painful, then
refactoring is called for and I want to hear about it.
> Thought 6
>
> One application of 'optional argument to option':
> script --log=x.log writes to x.log
> script --log writes to default-file-name
> script writes no log
Yeah, good example -- easier to grasp then my Distutils example.
Greg
--
Greg Ward - programmer-at-large gward@python.net
http://starship.python.net/~gward/
This quote intentionally left blank.