Get the latest tech news
The Pythonic Emptiness
Why the Pythonic way of doing emptiness check on sequences is not necessarily ambiguous in most cases
Finally, there is the possibility of silent bugs creeping in the system because the truthiness value based emptiness check can let objects of other types pass, whereas when you use len(), it will fail with TypeError. In Python, a language known for its simplicity and readable syntax, the idiomatic approach is to leverage the truthiness of sequences—where if not mylist: succinctly checks for emptiness, making a more elaborate len() call unnecessary unless the context demands. Ambiguity likely stems from other code issues, such as unclear variable names, absence of docstrings, missing type hints, lack of unit tests, and insufficient input validation.
Or read this on Hacker News