What is the most efficient way to test for False in a list?
Carsten Haese
carsten at uniqsys.com
Mon Jul 9 10:11:29 EDT 2007
On Mon, 2007-07-09 at 07:02 -0700, Paul McGuire wrote:
> >>> any(map(lambda _ : _ is False,[3,2,1,0,-1]))
> False
> >>> any(map(lambda _ : _ is False,[3,2,1,0,-1,False]))
> True
> >>>
Why the map/lambda? Is it faster than the more readable generator
expression?
>>> any(x is False for x in [3,2,1,0,-1])
False
>>> any(x is False for x in [3,2,1,0,-1,False])
True
--
Carsten Haese
http://informixdb.sourceforge.net
More information about the Python-list
mailing list