Kent Johnson wrote:
> Robert Hicks wrote:
>> idList only has about 129 id numbers in it.
>
> That is quite a few times to be searching each line of the file. Try
> using a regular expression search instead, like this:
>
> import re
> regex = re.compile('|'.join(idList))
> for line in f2:
> if regex.search(line):
> # process a hit
>
Since I am printing to a file like so:
[id]: [line]
I don't see how I can get the id back out of the regex.search like I
could in my code.
Robert
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor