What is wrong in my list comprehension?

Hussein B hubaghdadi at gmail.com
Sun Feb 1 06:22:36 EST 2009


Hey,
I have a log file that doesn't contain the word "Haskell" at all, I'm
just trying to do a little performance comparison:
++++++++++++++
from datetime import time, timedelta, datetime
start = datetime.now()
print start
lines = [line for line in file('/media/sda4/Servers/Apache/
Tomcat-6.0.14/logs/catalina.out') if line.find('Haskell')]
print 'Number of lines contains "Haskell" = ' +  str(len(lines))
end = datetime.now()
print end
++++++++++++++
Well, the script is returning the whole file's lines number !!
What is wrong in my logic?
Thanks.



More information about the Python-list mailing list