A few beginning questions

Robin Munn rmunn at pobox.com
Fri Jul 18 10:30:41 EDT 2003


Thomas Heller <theller at python.net> wrote:
> mis6 at pitt.edu (Michele Simionato) writes:
> 
>> "richardc" <richardc at hmgcc.gov.uk> wrote in message news:<3f129a8a$1 at mail.hmgcc.gov.uk>...
>>> Ive just started playing with Python and have a couple of questions.
>>> 
>>> Im looking for an agument parsing library (from the command line), Ive come
>>> across optik and argtools.  What other ones are there are any of them any
>>> good, is there a 'standard' lib for doing this.
>>>
>>
>> optparse (a.k.a. optik) is great, whereas I never made my mind up to
>> getopt. To "cure" getopt, I needed to define my own routines for
>> argument parsing; after I started using optparse I had the satisfaction
>> of erasing all of them ;)
> 
> I have not yet tried optparse. Is it able to parse Windows' style
> command lines (use '/' instead of '-', ignore case of command line
> options, use long options with a single '-' or '/')?
> 
> Thomas

No. From the optparse documentation:

    Some other option syntaxes that the world has seen include:

    + a hyphen followed by a few letters, e.g. -pf (this is not the same
      as multiple options merged into a single argument.)
    + a hyphen followed by a whole word, e.g. -file (this is technically
      equivalent to the previous syntax, but they aren't usually seen in
      the same program.)
    + a plus sign followed by a single letter, or a few letters, or a
      word, e.g. +f, +rgb.
    + a slash followed by a letter, or a few letters, or a word, e.g.
      /f, /file.

    optparse does not support these option syntaxes, and it never will.
    (If you really want to use one of those option syntaxes, you'll have
    to subclass OptionParser and override all the difficult bits. But
    please don't!  optparse does things the traditional Unix/GNU way
    deliberately; the first three are non-standard anywhere, and the
    last one makes sense only if you're exclusively targeting
    MS-DOS/Windows and/or VMS.)

(This is from http://www.python.org/doc/2.3b2/lib/optparse-terminology.html)

Is Windows-style arguments (with slashes) *that* important to you?
Because there's absolutely nothing wrong with following the standard
that's been established for over twenty years... :-)

-- 
Robin Munn <rmunn at pobox.com> | http://www.rmunn.com/ | PGP key 0x6AFB6838
-----------------------------+-----------------------+----------------------
"Remember, when it comes to commercial TV, the program is not the product.
YOU are the product, and the advertiser is the customer." - Mark W. Schumann




More information about the Python-list mailing list