[Tutor] Two Questions...(i) Checking for None (ii) Making

Greg Lindstrom gslindstrom at gmail.com
Sat Nov 4 14:41:43 CET 2006


> Date: Sat, 4 Nov 2006 10:36:58 +0000
> From: "Asrarahmed Kadri" <ajkadri at googlemail.com>
>

Hi Folks,
>
> I am trying to build a program which takes the following command-line
> arguments:
>
>    *-s <IP address> -D <start date> -n <no. of days> -t <start time>  <end
> time>*
>
> the first argument which is -s (for source) can be replaced by -d (for
> destination) or -o (for observer) or -r (for reporter). Now what I want is
> to make sure that the user only supplies one of the options from the 4
> alternatives.
>
> I am using 'optparse' module. It has got a nice feature taht enables you
> to
> give the option name, along with the variable-name to store the value of
> that option. The syntax is as under:


if you import sys you can use sys.argv to look at a list of all the command
line arguments (including the programs filename).  You should be able to
determine if you have duplicate flags ('-s','-d',etc).

hth
--greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061104/216e2556/attachment.html 


More information about the Tutor mailing list