[Tutor] Fastest way to iterate through a file

Robert Hicks sigzero at gmail.com
Sun Jul 1 22:31:39 CEST 2007

Alan Gauld wrote:
> "Robert Hicks" <sigzero at gmail.com> wrote 
>> This is the loop code:
>> for line in f2:
>>     for id in idList:
>>         if id in line:
>>             print "%s: %s" % (id, f2.next())
>>             found = "%s: %s" % (id, f2.next())
>>             f3.write(found)
> While I note that you got a solution using regex one general 
> point worth noting is that you should, in nested loop cases like 
> this, at least use break in the inner loop.

Do you mean after the write? That is a good suggestion and thanks for 
making it Mr. Gauld.


More information about the Tutor mailing list