[Tutor] Command lines args (getopt)
David Rock
david at graniteweb.com
Wed Aug 13 15:55:13 EDT 2003
* Justin Heath <justin at unixremedies.com> [2003-08-13 14:26]:
> All,
>
> I am getting upwards of single character arguments that make sense for a
> program I am writing. I am using getopt to parse the arguments. My
> question is I would like to use two character short options such as -lu
> (for local user) and -ru (for remote user). I know I can acomplish this
> (well almost) with long opts such as --ru, but I am trying to stay away
> from that. Any suggestions?
I would recommend just living with how the options are designed, an
extra hyphen won't kill you ;-)
If you MUST do it this way, try defining the short option so that it
expects a value (e.g. local user -> l:) and just treat the "u" as the
argument to the option. I have not tried this, but I see no reason why
this wouldn't work except if you have a -u option, maybe.
There is a new option parser in Python 2.3 that may have something
different for "long-short" options, but I have not looked in great
depth, yet.
--
David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20030813/d1c5c84c/attachment.bin
More information about the Tutor
mailing list