Thorsten Kampe wrote:
* 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

Sigh. I used dir /s /b as a simple Windows command with a flag (it could have been dir /s) because it was the first thing that popped into my mind.

I had no idea people were going to get so upset that I used a Windows example and go off on a tear.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to