any() and all() on empty list?

Ant antroy at gmail.com
Fri Mar 31 04:49:49 EST 2006


I don't think that there will be any valid examples.

all(list) simply means "every element of the list evaluates to True".
This is trivially true in the case of the empty list. This is logically
equivalent to "There are no elements in the list which evaluate to
False".

any(list) simply means "at least one element of the list evaluates to
true". This is trivially false for the empty list - there are no
elements to be true.

These are logical functions and should be mathematically sound. It's
possible to add all sorts of problems if we just arbitrarily decide
what "for all x" should mean. We may just as well decide that for
convenience: math.pi == 3.

-- 
Ant...




More information about the Python-list mailing list