optparse question

Thorsten Kampe thorsten at thorstenkampe.de
Sun Sep 19 10:23:10 CEST 2004

* GMTaglia (2004-09-18 23:39 +0200)
> George Yoshida wrote:
>> optparse is same as getopt in this respect.
> that's fine but....why?

To avoid unneccesary typing when the typed option is unambiguous. It's
the same with [y]es and [n]o. It makes things faster but increases
typo mistakes.
> I think it will be better if only the *exact* option will match, it will
> avoid typing mistakes and/or accidentally wrong matches, imho.

It won't avoid them but it will make them less likely. On the other
hand you could disable short options and make your long options at
least fifteen characters long to avoid typing mistakes and accidental
wrong matches.

*I* myself always use the complete long option when I use one but
maybe your users will find typing only a part comfortable?

On the other hand: if you have a lot of similar options, consider
renaming them so that they start with a different character or use a
config file (ConfigParser). May gpg be your guiding nightmare.


More information about the Python-list mailing list