KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I just found this : a = (None,) print (a is True) print (a is False) print (a == True) print (a == False) print (a == None) print (a is None) if a : print "hello" if not a : print "goodbye" which produces : False False False False False False hello So a neither is, nor equals True nor False, but acts as True in an if statement. Why? Update : actually, I've just realized that this isn't as obscure as I thought. I get the same result for a=2, as well (though not for a=0 or a=1, which are considered equal to False and True respectively)
Tags (comma-separated)
Save Edits
Cancel