Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
True == not False
#1
i read that True == not False is a syntax error ... but why?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
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
Reply
#3
Fascinating. But not False == True is not a syntax error.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#4
very interesting, however
safe:
>>> True != True
False
>>> True != False
True
>>> False != False
False
>>> False != True
True
>>>
But when would you ever need it?
Reply
#5
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
Good read about Python's True and False by Guido van Rossum: The story of None, True and False (and an explanation of literals, keywords and builtins thrown in)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#7
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.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between «1 in [2] == False» and «(1 in [2]) == False» fbaldit 2 2,238 Apr-20-2020, 05:39 PM
Last Post: fbaldit
  Do break operators turn while loop conditions from True to False? Drone4four 5 2,973 Oct-24-2019, 07:11 PM
Last Post: newbieAuggie2019
  Returning True or False vs. True or None trevorkavanaugh 6 9,263 Apr-04-2019, 08:42 AM
Last Post: DeaD_EyE
  Returning true or false in a for loop bbop1232012 3 8,154 Nov-22-2018, 04:44 PM
Last Post: bbop1232012
  saving a true/false of a single value Skaperen 3 2,507 Aug-20-2018, 02:31 AM
Last Post: ichabod801
  Get True of false outside a loop morgandebray 2 2,458 Aug-09-2018, 12:39 PM
Last Post: morgandebray
  True or false if running something? Artdigy 4 3,423 Mar-27-2018, 05:50 PM
Last Post: nilamo
  True vs False Skaperen 10 7,653 Jun-14-2017, 09:56 AM
Last Post: wavic
  How to turn variable true and false using function? hsunteik 5 6,505 Feb-20-2017, 11:44 AM
Last Post: hsunteik

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020