3 ms·
Besides the mentioned debunks of wat, the all([[[]]]) == True makes perfect sense, because the all all does is check the truthiness of the argument's eleme
by pvdebbe 11y ago
Besides the mentioned debunks of wat, the
all([[[]]]) == True
makes perfect sense, because the all all does is check the truthiness of the argument's elements. An empty list is false, non-empty is true, no matter the contents.
- agf 11y agoBy itself, yes, but >>> all([[[]]]) == True True >>> all([[]]) == True False >>> all([]) == True True is pretty counter-intuitive at first glance.
- pvdebbe 11y agoAt first glance, yes. Needs a moment to think this through. But not a wat because this works exactly as the logic says. If we denote x = [] then bool(x) == False # empty list is falsy bool([x]) == True # nonempty list is truthy bool([[x]]) == True # nonempty again and finally, [bool(elem) for elem in [[x]]] == [True] # all True! which is the thing `all' is interested in. It is more like a newbie mistake or careless document reading if the user thinks `all' runs through the lists and all of the nesting too.