What is the most efficient way to test for False in a list?
hniksic at xemacs.org
Mon Jul 9 14:39:10 CEST 2007
"Diez B. Roggisch" <deets at nospam.web.de> writes:
>>>> but what is your best way to test for for False in a list?
>>> status = all(list)
>> Am I mistaken, or is this no identity test for False at all?
> You are mistaken.
> all take an iterable and returns if each value of it is true.
Testing for truth is not the same as an identity test for False. OP's
message doesn't make it clear which one he's looking for. This
illustrates the difference:
>>> False in [3, 2, 1, 0, -1]
True # no False here
>>> all([3, 2, 1, 0, -1])
False # false value present, not necessarily False
More information about the Python-list