Delete all items in the list

Terry Reedy tjreedy at udel.edu
Thu Feb 26 15:27:38 EST 2009


Steve Holden wrote:
> Terry Reedy wrote:
>> Gabriel Genellina wrote:
>>
>>>> L = filter('a'.__ne__,L)
>>> And this is probably the fastest. But not all types define __ne__ 
>> In Py3, all classes inherit .__ne__ from 'object'.
>>
> Isn't that inherited method just an identity comparison?

Yes.  And so is, by default, the snipped slower proposed alternative of 
lambda x: a!= x.

> However in this particular case the main point is that str *does*
> implement __ne__. So as long as that built-in method doesn't call the
> other operand's __ne__ there should be no problem.
> 
> regards
>  Steve




More information about the Python-list mailing list