Another newbie getopt thread. ^_^

John Lenton jlenton at
Sun Jul 18 15:47:37 CEST 2004

On 18 Jul 2004 00:53:16 -0700, googleboy <mynews44 at> wrote:
> The docs and examples don't make it clear how to do this,  and when I
> defined a -h, --help option it gave me a conflict error:
> optik.errors.OptionConflictError: option -h/--help: conflicting option
> string(s): -h, --help
> Is there anyway around this?

OptionParser has a add_help_option that defaults to 1; also, a 'usage'
parameter that you can override the message that appears _before_ the

And you can always subclass OptionParser...

> Finally,  a quick one...  Is there a way for optparse to force an
> integer to be between 0 and 100?  I am passing in percentage
> values....  It isn't hard to make a validation on the integers
> afterwards,  but I thought it might be nice to have this as part of
> the optparse.

doesn't make_option help you do this?

John Lenton (jlenton at -- Random fortune:
bash: fortune: command not found

More information about the Python-list mailing list