What is the most efficient way to test for False in a list?

Paul Rubin http
Mon Jul 9 17:05:14 CEST 2007


"Diez B. Roggisch" <deets at nospam.web.de> writes:
> >> 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.

all(list) does what the OP's code did, tests for the presence of a false
value in the list.  If you want an identity test, use 

  status = not (False in list)



More information about the Python-list mailing list