[Fwd: Re: [Tutor] searching for data in one file from another]
Rich Krauter
rmkrauter at yahoo.com
Sat Nov 6 06:52:22 CET 2004
Kent Johnson wrote:
> When you read f2 with readlines, the newlines are included in the lines.
> So you will never get a match with the exon from f1. Also since you are
> apparently doing many tests for membership in list, a set would probably
> be faster. I suggest you try something like this to create 'list':
>
> from sets import Set
> list = Set()
> for line in open(exons_to_delete):
> list.add(line.strip())
>
> The rest of the program stays the same, including the test 'if exon in
> list'
>
> You might want to use a different name for 'list' though.
Kent,
Thanks very much for the reply. Right on the money and within a few
minutes, as usual. I'm starting to think you're an automated help
system. The OP should find these suggestions helpful for cleaning up his
code.
Rich
More information about the Tutor
mailing list