[Tutor] Comparing two lists

Michael Powe michael at trollope.org
Thu Sep 16 20:27:28 CEST 2010


I have two lists.

alist = ['label', 'guid']

blist = ['column0label', 'column1label', 'dimension0guid',
'description', 'columnid'] 

I want to iterate over blist and extract the items that match my
substrings in alist; alternatively, throw out the items that aren't in
alist (but, I've had bad experiences removing items from lists "in
place," so I tend toward the "copy" motif.)

In real life, blist column entries could have embedded column numbers
from 0 to 19.

I can do this with excrutiatingly painful 'for' loops.  Looking for
something more efficient and elegant.  



Michael Powe		michael at trollope.org		Naugatuck CT USA

"The secret to strong security: less reliance on secrets."
-- Whitfield Diffie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20100916/7657d1ae/attachment.pgp>

More information about the Tutor mailing list