Most efficient solution?
Alexandre Fayolle
alf at leo.logilab.fr
Mon Jul 16 11:38:46 EDT 2001
On 16 Jul 2001 11:06:41 -0400, Alex <new_name at mit.edu> wrote:
>
>> C = {}
>> for item in B:
>> C[item] = 1
>>
>> A = filter(C.get, A)
>
>I guess that'll drop some elements from A that are in B but evaluate to
>false, though.
I'm pretty sure this will work, though I've not tested. C.get(item) will
return None (thus false) if item was not in B, and 1 (thus true) if item
was in B. You should definitely give a try to this version.
Alexandre Fayolle
--
LOGILAB, Paris (France).
http://www.logilab.com http://www.logilab.fr http://www.logilab.org
Narval, the first software agent available as free software (GPL).
More information about the Python-list
mailing list