3 ms·
There are Python idioms for exactness, and idioms for truthiness. When in a situation where it's possibly ambiguous to test truthiness 'if x is None:' or 'if x
by jhayward 7y ago
There are Python idioms for exactness, and idioms for truthiness. When in a situation where it's possibly ambiguous to test truthiness 'if x is None:' or 'if x is True': is completely unambiguous.
Most code doesn't need that and the truthiness nature of various data types is helpful in writing clear code.