Re:What the Fuck Python
by 3eb7988a1663 on Saturday July 19, 2025 @05:49PM
(#44619750)
prefer bool() threw an exception on receiving a string, rather than act the way it does now.
That breaks the truthiness cornerstone of the language. You can write
a = 1 # or [], (), "yo", "false", 3.2, MyFooClass(), (1,), False
if a:
fire_ze_missles()
else:
declare_peace()
Upon encountering `a`, Python is evaluating bool(a). If that no longer works for strings, you now need a separate code path for determining a non-empty string.
It can short-circuit the brain upon reading a word that you know means false, but the Python rules are consistent. "Empty" is False, everything else is True.
It can short-circuit the brain upon reading a word that you know means false, but the Python rules are consistent. "Empty" is False, everything else is True.