How best to write this if-else?
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Sat Apr 21 17:02:07 EDT 2001
Sat, 21 Apr 2001 16:02:46 -0400, Roy Smith <roy at panix.com> pisze:
[...]
> Is there really no more straight-forward way to do what I want?
regexps = map(re.compile, ['...', '...', '...'])
# Or in Python >= 2.0:
# regexps = [re.compile(r) for r in ['...', '...', '...']]
for r in regexps:
m = r.match(line)
if m:
text = m.group(1)
break
else:
# None matched.
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list