Re:The 2,500 year old history of why Python’s all([]) return...
by Salgat on Friday August 25, 2023 @07:55PM
(#37268511)
"all" and "none" are simultaneously true, which makes this a tricky edge case that needs to be explicitly accounted for.
[ Parent
| on HN ]
Re:The 2,500 year old history of why Python’s all([]) return...
by dragonwriter on Friday August 25, 2023 @08:02PM
(#37268550)
Its necessary that all and none are both true of empty lists, if they are both defined for empty lists, because otherwise the invariant that all(xs) == none(not x for x in xs) [0] would not hold.
[0] yes, “none()” doesn’t actually exist in Python, but we can imagine that it did, and see that if it did, it should have this relationship.)