Who knows why I wrote that without a for loop before?

This commit is contained in:
Jeremy Fincher 2004-02-16 00:54:05 +00:00
parent 487fb3cc2f
commit ff370e29cf

View File

@ -224,27 +224,24 @@ def separateModes(args):
assert modes[0] in '+-', 'Invalid args: %r' % args assert modes[0] in '+-', 'Invalid args: %r' % args
args = list(args[1:]) args = list(args[1:])
ret = [] ret = []
index = 0
length = len(modes) length = len(modes)
while index < length: for c in modes:
if modes[index] in '+-': if c in '+-':
last = modes[index] last = c
index += 1
else: else:
if last == '+': if last == '+':
requireArguments = _plusRequireArguments requireArguments = _plusRequireArguments
else: else:
requireArguments = _minusRequireArguments requireArguments = _minusRequireArguments
if modes[index] in requireArguments: if c in requireArguments:
arg = args.pop(0) arg = args.pop(0)
try: try:
arg = int(arg) arg = int(arg)
except ValueError: except ValueError:
pass pass
ret.append((last + modes[index], arg)) ret.append((last + c, arg))
else: else:
ret.append((last + modes[index], None)) ret.append((last + c, None))
index += 1
return ret return ret
def joinModes(modes): def joinModes(modes):