command line arguments
Jon Hewer
jonhewer at gmail.com
Wed Aug 31 11:33:48 EDT 2005
hi
i am writing a little script and currently implementing command line
arguments following the guide by mark pilgrim from dive into python;
http://diveintopython.org/scripts_and_streams/command_line_arguments.html
thats all fine, however i am not sure of the BEST way to handle
multiple command line arguments
for my script, i want to be able to accept two arguments, a name and a
url, but i am not sure if its best to use one command line option/flag
(eg -n to specify name) and then grab the url from the extra data
which will be in 'args':
opts, args = getopt.getopt(sys.argv[1:], "n:", ["name="])
or to have two command line options/flags, -n and -u, and checking
that these have both been specified and then proceeding (this might be
a little messier)
any tips would be much appreciated
thanks in advance
jon
More information about the Python-list
mailing list