[Tutor] Searching list items.
Chris Hengge
pyro9219 at gmail.com
Tue Oct 17 23:54:14 CEST 2006
I remove those lines, but I was trying to use
for line in contents:
result = re.search("something", line)
print result
this printed out something like
None
None
None
hex memory address of goodness
None
None
...
On 10/17/06, Luke Paireepinart <rabidpoobear at gmail.com> wrote:
>
> Chris Hengge wrote:
> > contents = readlines(myfile, 'r')
> > Ok, I'm under the impression this is a list of strings (array)
> Nope. No such thing as arrays in Python.
> It is a list of strings, that's it. :)
> > How in the world do I cycle through them looking for words?
> >
> > for line in contents:
> > if line.contains("something")
> > print line
> >
> > Thats a mock up of what I'm looking for.
> > I tried to figure out how to use re, but that spits out locations in
> > memory or none it seems.
> You'd use regular expressions or use
> if 'astring' in line:
>
> if your use case is simple enough for that.
> show us what RE you used that gave you trouble.
> It's hard to help when we don't know where you're getting stuck :)
> >
> > Thanks.
> Sure.
>
> -Luke
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061017/a6f36bc7/attachment.html
More information about the Tutor
mailing list