[getopt-sig] ANNOUNCE: Optik 1.3 released
Greg Ward
gward@python.net
Sat, 13 Apr 2002 10:52:26 -0400
On 12 April 2002, David Goodger said:
> Yes, and wrong too. Either the -f option takes an argument, or it doesn't.
> Optik is explicit about this. Some people want optional option arguments,
> but that makes parsing (in cases like this) ambiguous and is best avoided.
Thanks David -- I was going to reply along those lines, but you got
there faster and put it better.
FWIW, I actually did put some effort into implementing optional option
arguments for Optik. It wasn't fun. It would require completely
rewriting the central argument-parsing loop, which I wasn't keen on. I
might still do it as an example, but I haven't figured out how to do it
right yet.
> If optional option arguments were allowed, this case would be ambiguous. To
> resolve it you'd have to specify that the "optional option argument options"
> are "greedy" (they try to take an argument first), or "non-greedy" (try to
> match options first). But what if you then want to pass an option argument
> which begins with a hyphen, like a file named "-dash.txt"? Doesn't work.
That's a useful insight. I think you've thought longer and harder about
this than I have. Thanks!
Greg
--
Greg Ward - geek-at-large gward@python.net
http://starship.python.net/~gward/
Do radioactive cats have 18 half-lives?