On Tue, Jan 4, 2011 at 07:55, Wayne Werner <waynejwer...@gmail.com> wrote: > On Tue, Jan 4, 2011 at 9:37 AM, Richard D. Moores <rdmoo...@gmail.com>
> You could use (2.6+ I think): > word = raw_input('Enter word to search for: ') > with open('somefile.txt') as f: > for line in f: > if word in line: > print line I think I do need a regex for cases such as this: A file has these 2 lines: alksdhjf ksjhdf kjshf dex akjdhf jkdshf jsdhf alkdshf jkashd flkjdsf index alkdjshf alkdjshf And I want the only line that contains the word "dex" Dick _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor