Most efficient solution?

Simon Brunning SBrunning at
Mon Jul 16 10:19:53 EDT 2001

> From:	Jeffery D. Collins [SMTP:jcollins at]
> > List B consists of my "stopwords", meaning, the words I don't want
> included in my final version of list A. So what I need to 
> > do is check every item in list A, and if it occurs in list B, then I
> want to remove it from the final version of A. My first thought 
> > would be:
> > 
> > for eachItem in A:
> >     if eachItem in B:
> >         A.remove(eachItem)
> > 
> How about: 
> map(A.remove, B)
Clever! Unfortunately, it dies (giving a ValueError) if any of the tokens in
B are not present in A. Nasty, but how about:

map((A + B).remove, B)

Simon Brunning
TriSystems Ltd.
sbrunning at

The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.

More information about the Python-list mailing list