optparse question

John Machin sjmachin at lexicon.net
Tue Jan 27 14:31:42 CET 2009


On Jan 28, 12:06 am, Pat <P... at junk.net> wrote:
> 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.

Nobody is upset, and nobody has "gone off on a tear". The point about
the "Windows example" is that the docs say in a close-to-screamingly-
obvious manner that /options are not supported, no matter what
religion uses them. It was not, and still is not, apparent what you
really wanted. We're all patiently waiting for you to rephrase the
question(s).



More information about the Python-list mailing list