Re: Equivalent string.find method for a list of strings

2005-04-12 Thread jeremit0
jeremit0 wrote: I have read a text file using the command lines = myfile.readlines() and now I want to seach those lines for a particular string. I was hoping there was a way to "find" that string in a similar way as searching simply a simple string. I want to do something like

Re: Equivalent string.find method for a list of strings

2005-04-08 Thread jeremit0
Steven Bethard wrote: jeremit0 wrote: Steve Holden wrote: If you want line numbers,. of course, then you can use for linenum, line in enumerate(myfile.readlines()): ... Remember that true to Python's philosophy numbering will start at zero. Is this any better than:

Re: Equivalent string.find method for a list of strings

2005-04-08 Thread jeremit0
Steve Holden wrote: jeremit0 wrote: harold fellermann wrote: file.readlines() returns a list of lines. You can either call find on each element in this list, like: for line in myfile.readlines() : if line.find('my particular string') : do_something() I had thought that

Re: Equivalent string.find method for a list of strings

2005-04-08 Thread jeremit0
harold fellermann wrote: file.readlines() returns a list of lines. You can either call find on each element in this list, like: for line in myfile.readlines() : if line.find('my particular string') : do_something() I had thought that may be the only way to do it, I was hoping for somet

Equivalent string.find method for a list of strings

2005-04-08 Thread jeremit0
I have read a text file using the command lines = myfile.readlines() and now I want to seach those lines for a particular string. I was hoping there was a way to "find" that string in a similar way as searching simply a simple string. I want to do something like lines.find.('my particular stri