Odd truth result with in and ==

Alan Bawden alan at csail.mit.edu
Fri Nov 23 22:57:03 EST 2018


Chris Angelico <rosuav at gmail.com> writes:

> Or you could say "not [1,2,3] == not True",
> but that's a bit less clear....

It's less clear in more ways than one:

   3.6> not [1,2,3] == not True
     File "<stdin>", line 1
       not [1,2,3] == not True
                        ^
   SyntaxError: invalid syntax
   3.6> not [1,2,3] == (not True)
   True
   3.6> not [] == (not True)
   True
   3.6> (not []) == (not True)
   False

-- 
Alan Bawden



More information about the Python-list mailing list