any(), all() and empty iterable

John O'Hagan research at
Sun Apr 12 18:20:03 CEST 2009

On Sun, 12 Apr 2009, Paul Rubin wrote:
> Tim Chase <python.list at> writes:
> > >                 Return True if all elements of the iterable are
> > > true. ...
> >
> > Then I'd say the comment is misleading.  An empty list has no item
> > that is true (or false), yet it returns true.
> The comment is correct.  "All the items of the iterable are true"
> means EXACTLY the same thing as "there are no items of the iterable
> that are false".  The empty list has no false items.  Therefore
> all(empty_list) = True is the correct behavior.


By the same argument, all the items of the iterable are also False, or blue, 
or anything else you care to say about them, because there aren't any. From 
the Wikipedia article on vacuous truth (see Chris Rebert's reply in this 

"All pink rhinoceros are carnivores."
"All pink rhinoceros are herbivores."

But you're right, by this logic the comment is correct, and although the 
choice of True seems arbitrary, I've learnt something about logic today.



More information about the Python-list mailing list