Using optparse

Piet van Oostrum piet at
Thu Apr 23 17:43:27 CEST 2009

>>>>> loial <jldunn2000 at> (L) wrote:

>L> A shell script is passing parameters to my python script in the
>L> following format

>L> -PARAM1 12345 -PARAM2 67890

>L> Can I parse these with optparse  ? If so how?

>L> I can't seem to get it to work. It seems to expect --PARAM1 and --

See the doc:

Some other option syntaxes that the world has seen include:
    * a hyphen followed by a whole word, e.g. "-file" [...]

These option syntaxes are not supported by optparse, and they never will be.

Piet van Oostrum <piet at>
URL: [PGP 8DAE142BE17999C4]
Private email: piet at

More information about the Python-list mailing list