Using dictionary to hold regex patterns?
Gilles Ganault
nospam at nospam.com
Sun Nov 23 17:48:01 EST 2008
On Sun, 23 Nov 2008 17:55:48 +0000, Arnaud Delobelle
<arnodel at googlemail.com> wrote:
>But there is no reason why you should use a dictionary; just use a list
>of key-value pairs:
Thanks for the tip. I didn't know it was possible to use arrays to
hold more than one value. Actually, it's a better solution, as
key/value tuples in a dictionary aren't used in the order in which
they're put in the dictionary, while arrays are.
For those interested:
========
response = ">dummy</td>bla>good stuff</td>"
for name, pattern in patterns:
m = pattern.search(response)
if m:
print m.group(1)
break
else:
print "here"
========
Thanks guys.
More information about the Python-list
mailing list