Is (-1 ==True) True or False? Neither
steve at REMOVE-THIS-cybersource.com.au
Sun Jan 25 13:21:31 CET 2009
On Sun, 25 Jan 2009 03:07:04 +0200, Oktay Şafak wrote:
> The reason is that when
> someone writes (-1 == True) he is clearly, definitely, absolutely asking
> for a boolean comparison, not a numerical one.
If I wrote (-1 == True), and I'm not sure why I would, I would expect to
get the answer False, because -1 is not equal to True. Many things have
truth values which are true but not equal to True.
If I wanted bool(-1) == True, I'd write bool(-1) == True. Or, if I was in
a whimsical mood, I'd write:
((bool(-1) == True) == True) == True # oh when to stop???
just to illustrate the foolishness of doing boolean equality comparisons
More information about the Python-list