Command line arguments
Padraig Brady
padraig.brady at corvil.com
Thu Jan 9 05:18:51 EST 2003
Dusausoy Bruno wrote:
> Hi,
>
> I'd like to have a program that is called like this :
>
> prog [OPTIONS] [FILES]
>
> I use the getopt module for the options but i don't know how to catch
> the FILES arguments. Can someone help me ?
try:
options, files = getopt.getopt(sys.argv[1:], '', ["option1"])
#if something wrong: raise "error"
for o, a in opts:
if o == "--option1": pass #...
except:
print >> sys.stderr, "Usage: "+ sys.argv[0] + " [OPTIONS] [FILES]"
sys.exit(1)
Pádraig.
More information about the Python-list
mailing list