Equality operator

Kent Johnson kent37 at tds.net
Sat Mar 5 15:57:24 EST 2005


italy wrote:
> Why doesn't this statement execute in Python:
> 
> 1 == not 0
> 
> I get a syntax error, but I don't know why. 

Because == has higher precedence than 'not', so you are asking for
(1 == not) 0

Try
 >>> 1 == (not 0)
True

Kent

> 
> Thanks,
> Adam Roan
> 



More information about the Python-list mailing list