So I get some input in python that I need to parse using regexps.
At the moment I'm using something like this:
matchOK = re.compile(r'^OK\s+(\w+)\s+(\w+)$')
matchFailed = re.compile(r'^FAILED\s(\w+)$')
#.... a bunch more regexps
for l in big_input:
match = matchOK.search(l)
if match:
#do something with match
continue
match = matchFailed.search(l)
if match:
#do something with match
continue
#.... a bunch more of these
# Then some error handling if nothing matches
Now usually I love python because its nice and succinct. But this feels verbose. I'd expect to be able to do something like this:
for l in big_input:
if match = matchOK.search(l):
#do something with match
elif match = matchFailed.search(l):
#do something with match
#.... a bunch more of these
else
# error handling
Am I missing something, or is the first form as neat as I'm going to get?