3 ms·
You're assuming that the condition of "if" is necessarily a boolean. Indeed. Conditional branching generally needs a boolean value - do we go down this path o
by xiongchiamiov 16y ago
You're assuming that the condition of "if" is necessarily a boolean.
Indeed. Conditional branching generally needs a boolean value - do we go down this path or not?
It's not clear that it is. It looks more like "is the value not an element of [None, 0, 0.0, False, {objects of 0 length}]" and a couple of others.
Right, and any of those things, when converted to a boolean are... False. The things that don't convert to True.
I don't know how the language itself is constructed, but it would surprise me if the code for bool() and if-statements were logically separated. Can you imagine the havoc that would ensue from, say, bool(None) returning False, but if None: causing the branch to execute?