[Tutor] How to find a substring within a list of items

Richard Querin rfquerin at gmail.com
Thu Jan 13 19:10:42 CET 2011


I have an object that contains about 3500 list items, each list containing
various data, some strings and some floats, like so:

['D', 123.4,'This is a project description', 'type', 52.1,'title']

What is the easiest way to search this list for a given string? So I want to
find out if this list contains the string 'scrip' anywhere within it (case
insensitive and including being just part of a larger string).

Incidentally, I'm using the xlrd module to read in a spreadsheet. I
effectively want to quickly pull out a list of lines from that spreadsheet
that contain that substring anywhere within them. Maybe there is a
better/faster way I should be doing this?

I'm trying to give employees here a better/faster way of filtering through
the company project list rather than opening up excel and doing a find
search each time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110113/d06be7fc/attachment.html>


More information about the Tutor mailing list