noro wrote:

> Is there a more efficient method to find a string in a text file then:
>
> f=file('somefile')
> for line in f:
>     if 'string' in line:
>          print 'FOUND'
>
> ?

Is this something you want to do only once for a given file ? The
replies so far seem to imply so and in this case I doubt that you can
do anything more efficient. OTOH, if the same file is to be searched
repeatedly for different strings, an appropriate indexing scheme can
speed things up considerably on average.

George

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to