[Tutor] getopt question

Tim Condit timc@ans.net
Thu, 27 Jul 2000 18:07:29 -0400 (EDT)


Hi, I'm having some confusion with the getopt module. Is there a better
way to do this? 

--

#!/usr/local/bin/python

import getopt
import sys

try:
    options, argument = getopt.getopt(sys.argv[1:], 'hbt')
except getopt.error:
    print "getopt.error - sorry."
    sys.exit(0)

for i in range(len(options)):
    if '-h' in options[i]:
        print "You need help"
    if '-b' in options[i]:
        print "You need bash"
    if '-t' in options[i]:
        print "You need tcsh"


[timc@neutrino ~/py] ./getopt_test.py -t -h -b
You need tcsh
You need help
You need bash

--

Thanks in advance, 

Tim Condit
UUNet Network Quality Services
734-214-7548
tcondit@uu.net