optparse question
Thorsten Kampe
thorsten at thorstenkampe.de
Tue Jan 27 04:45:13 EST 2009
* Pat (Mon, 26 Jan 2009 20:02:59 -0500)
> Up until today, I never needed to pass any arguments to a Python
> program.
> [...]
> getopt resolved my immediate need, but I would like to know how one
> could use optparse to extract out the options from something like "dir
> /s /b".
If you actually read the documentation (it's right at the top) you knew
that this is not possible:
"There are many different syntaxes for options; the traditional Unix
syntax is a hyphen (“-“) followed by a single letter [...] The GNU
project introduced "--" [...] These are the only two option syntaxes
provided by optparse.
Some other option syntaxes that the world has seen include:
[...]
a slash followed by a letter, or a few letters, or a word, e.g. "/f",
"/file"
These option syntaxes are not supported by optparse, and they never will
be. This is deliberate: [...] the last only makes sense if you’re
exclusively targeting VMS, MS-DOS, and/or Windows."
Thorsten
More information about the Python-list
mailing list