Roald de Vries wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed">On Aug 5, 2010, at 5:42 PM, wheres pythonmonks wrote:
How does "x is not None" make any sense? "not x is None" does make sense.

I can only surmise that in this context (preceding is) "not" is not a
unary right-associative operator, therefore:

x is not None === IS_NOTEQ(X, None)

Beside "not in" which seems to work similarly, is there other
syntactical sugar like this that I should be aware of?

'not None' first casts None to a bool, and then applies 'not', so 'x is not None' means 'x is True'.
'not x is None' is the same as 'not (x is None)'

Cheers, Roald

Did you try it?

Python 2.6.4 (r264:75706, Jan 22 2010, 16:41:54) [MSC v.1500 32 bit
win32
Type "help", "copyright", "credits" or "license" for more informatio
>>> 4 is not None
True
>>> True is not None
True
>>> False is not None
True
>>> None is not None
False
>>>

Looks to me like
  x is not None

is equivalent to
  not (x is None)

(I get same results for 3.1)

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to