Python Forum

Full Version: True == not False
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i read that True == not False is a syntax error ... but why?
This actually surprised me, which goes to show how rarely you would write == followed by not I suppose. I assumed it would work but nope; it is indeed a syntax error.

Anyway:
https://stackoverflow.com/a/6100328
Fascinating. But not False == True is not a syntax error.
very interesting, however
safe:
>>> True != True
False
>>> True != False
True
>>> False != False
False
>>> False != True
True
>>>
But when would you ever need it?
change "==" to "is" and it works OK. but i cannot imagine ever needing it. i read this while reading the library reference and it piqued my curiosity. i wonder if it is a syntax error for all the interpreters/compilers.
True == not False
can be written as:
True == != False
which is also a syntax error.

Use instead:
True != False

PS: In our company we make jokes about double negation.