Socrates, Python, and why does all() return True if iterator is empty?
AI summary of the linked articlePython's all() returns True for an empty iterable because it follows modern predicate logic, one side of a roughly 2,500-year-old philosophical debate. Under the older Aristotelian system, "all unicorns are blue" was false because no unicorns exist, while modern logic treats it as true because no unicorns fail to be blue. Peter Abelard (12th century) identified a problem with the older system, and a new predicate logic replaced it in the nineteenth century. The Python core team chose this behavior, and programmers can work around it with wrapper functions or if tests. |
Comments No comments yetWhat caught your eye? Start the discussion. |
