You must be thinking of languages that convert operands to a common type before checking for equality. This is not how Python works. As you can read here, the rules for equality are pretty complex; but they boil down to this:
The default behavior for equality comparison (== and !=) is based on the identity of the objects.
So all non-empty strings are "interpreted as true" (as are most objects, other than empty containers and a couple of constants); but they are not equal to each other, and they are not equal to the constant True
.
"Interpreted as true" basically means that they make a conditional come out true, and that conversion to boolean (with bool()
) will give the value True
.
PS. Just for fun, note that the following does hold:
>>> print(1 == True)
True
Yes, the constant True
just happens to be equal to the integer 1
. Why not?