Yuval Greenfield writes:
In python 3.2.3:
>>> 1 == True True * >>> 13 == True* * False* >>> bool(1) True >>> bool(13) True >>> 1 is True False >>> 13 is True False
To my surprise identity is actually less confusing than equality. So I agree with Antoine and Michael on that point.
FWIW, I don't find any of the above confusing. "1 == True" => True is unexpected in some sense, but I don't find it counter-intuitive, and I find the "don't break old code" rationale satisfactory. Inada-san's example of addition is a little disconcerting in that particular spelling. But sum(predicate(x) for x in seq) seems preferable to a boolean-specific count function, and it generalizes nicely to the creation of dummy variables in statistical applications. Steve