[Tutor] getopt matching incorrect options

Jay Loden python at jayloden.com
Mon Jul 11 04:51:20 CEST 2005

I have an app that takes a command line argument of -l or --list.  It uses the getopt module to parse the arguments, and I just noticed that for some reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in below)

Is this normal behavior, and if so, is there any way to avoid this? I just want it to match "--list" to "--list", not "--l" and "--li" and "--lis" etc. 


###### Code chunk below ######

                options,args = getopt.getopt(sys.argv[1:], "Rf:shvl", ["list", "full-restart=", "full-restart-all", "status-all", "help", "version"])
 except getopt.GetoptError:
                # print help information and exit:

                if opt in ("-l", "--list"):

More information about the Tutor mailing list