4 ms·
At 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)
by pvdebbe 11y ago
At 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.