Re: Equality operator

2005-03-05 Thread Anthony Boyd
italy wrote: > Why doesn't this statement execute in Python: > > 1 == not 0 > > I get a syntax error, but I don't know why. > > Thanks, > Adam Roan Of course, you would normally want to use != to see if something is not equal to something else. 1 != 0 True -- http://mail.python.org/mailman/lis

Re: Equality operator

2005-03-05 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, italy wrote: > Why doesn't this statement execute in Python: > > 1 == not 0 > > I get a syntax error, but I don't know why. `==` has a higher precedence than `not` so Python interprets it as:: (1 == not) 0 This works:: >>> 1 == (not 0) True Ciao, Marc

Re: Equality operator

2005-03-05 Thread Chris Grebeldinger
"not" has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error. http://docs.python.org/lib/boolean.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Equality operator

2005-03-05 Thread Marek Kubica
> Why doesn't this statement execute in Python: > > 1 == not 0 > > I get a syntax error, but I don't know why. This does: 1 == (not 0) I presume Python treats it like 1 (== not) 0 Which is a SyntaxError greets, Marek -- http://mail.python.org/mailman/listinfo/python-list

Re: Equality operator

2005-03-05 Thread Kent Johnson
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 -- http://mail.python.org/mailman/listinfo/python-list