@@ -68,7 +68,7 @@ def getopt(args, shortopts, longopts = []):
6868 if args [0 ] == '--' :
6969 args = args [1 :]
7070 break
71- if args [0 ][: 2 ] == '--' :
71+ if args [0 ]. startswith ( '--' ) :
7272 opts , args = do_longs (opts , args [0 ][2 :], longopts , args [1 :])
7373 else :
7474 opts , args = do_shorts (opts , args [0 ][1 :], shortopts , args [1 :])
@@ -124,7 +124,8 @@ def do_shorts(opts, optstring, shortopts, args):
124124 if short_has_arg (opt , shortopts ):
125125 if optstring == '' :
126126 if not args :
127- raise GetoptError ('option -%s requires argument' % opt , opt )
127+ raise GetoptError ('option -%s requires argument' % opt ,
128+ opt )
128129 optstring , args = args [0 ], args [1 :]
129130 optarg , optstring = optstring , ''
130131 else :
@@ -135,7 +136,7 @@ def do_shorts(opts, optstring, shortopts, args):
135136def short_has_arg (opt , shortopts ):
136137 for i in range (len (shortopts )):
137138 if opt == shortopts [i ] != ':' :
138- return shortopts [ i + 1 : i + 2 ] == ':'
139+ return shortopts . startswith ( ':' , i + 1 )
139140 raise GetoptError ('option -%s not recognized' % opt , opt )
140141
141142if __name__ == '__main__' :
0 commit comments