optparse variable parsing?
CJ Kucera
python at apocalyptech.com
Tue Mar 9 09:42:37 EST 2004
David Goodger wrote:
> An "option argument". The answer is no, optparse doesn't support
> optional option arguments. The main reason is that it makes a command
> like "cmd -abc" impossible to parse reliably: is it equivalent to
> "cmd -a bc" or to "cmd -a -b -c"? In the Python tradition, optparse
> chooses not to guess.
Yeah, true, there is a measure of ambiguity there. In that case I
suppose I'd prefer to just sort of "require" the dashes to signify
options, if there's a question as to what's an option and what's
not, but whatever...
> I would suggest that you should have two different options here, a
> simple switch and an option which expects/requires an argument.
> That's easier to document as well.
Yeah, that's what I've been doing, it's just a bit tight because
right now the program already accepts fourteen options, and finding
options that make sense while keeping them down to one-letter
arguments (don't like having to have more than one letter per arg)
can get a bit challenging. :)
Well, thanks for the confirmation!
-CJ
--
WOW: Kakistocracy | "The ships hung in the sky in much the same
apocalyptech.com/wow | way that bricks don't." - Douglas Adams,
python at apocalyptech.com | _The Hitchhiker's Guide To The Galaxy_
More information about the Python-list
mailing list