Documentation:
all(iterable)
: ReturnTrue
if all elements of the iterable are true (or if the iterable is empty).
However, I can't explain results 4 and 5 below using Python3:
tupleData = ((1), (1, 4), (2, 3))
returnTrue
(OK)tupleData = ((0), (1, 4), (2, 3))
returnsFalse
(OK)tupleData = ((None), (1, 4), (2, 3))
returnsFalse
(OK)tupleData = ((0, None), (1, 4), (2, 3))
returnsTrue
(Why?)tupleData = ((), (1, 4), (2, 3)
) returnsFalse
(Why, isn't it supposed to returnTrue
if the iterable is empty?
Thanks everyone, especially Barmar. With the points you mentioned now I understand these outputs: any() and all() here iterate over the top-level tuple (and not the nested tuples). an empty nested tuple is considered a False element in the top-level tuple, and vice versa.