try:

filter(lambda x: lines[x].find(searchstring) != -1, range(len(lines)))

That will return a list with the indices of every line containing a hit for your search string.

-jag

<<inline: Pasted Graphic.tiff>>


Joshua Ginsberg -- [EMAIL PROTECTED] Brainstorm Internet Network Operations 970-247-1442 x131 On Apr 8, 2005, at 1:52 PM, Jeremy Conlin wrote:

Joshua Ginsberg wrote:

Try:

filter(lambda x: x.find(searchstring) != -1, lines)

I really like this option, but what I want to know where in the file this line exists (i.e. line 42). Can I somehow access this line and the lines immediately following?
Thanks,
Jeremy


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

Reply via email to