Delete all items in the list
John Posner
jjposner at snet.net
Thu Feb 26 10:44:03 EST 2009
>>
>> > L = filter('a'.__ne__,L)
>>
>> And this is probably the fastest. But not all types define
>> __ne__ so a
>> more generic answer would be:
>>
>> from functools import partial
>> from operator import ne
>> L = filter(partial(ne, 'a'), L)
>>
And don't forget this "traditional" solution:
>>> L=['a', 'b', 'c', 'a']
>>> filter(lambda arg: arg != 'a', L)
['b', 'c']
-John
E-mail message checked by Spyware Doctor (6.0.0.386)
Database version: 5.11850
http://www.pctools.com/en/spyware-doctor-antivirus/
More information about the Python-list
mailing list