I know it has a good reason, but I want to know what reason?
>>> print all([])
True
If all() is intended to check if every item on
Suppose all([])
is False
.
Then, for all non empty list A
, all(A + [])
should be also False
as
all(A + []) = all(A) and all([])
= all(A) and False
= False
Since A + [] = A
, we know
all(A + []) = all(A) for any non empty list A
But, all(A)
could be True
(e.g., A = [True]
)
Hence,
for all non empty list
A
,all(A + [])
should be alsoFalse
This contradicts. As a result, the first assumption is wrong and
all([])
is True