easy question on parsing python: "is not None"

Roald de Vries downaold at gmail.com
Thu Aug 5 12:35:53 EDT 2010


On Aug 5, 2010, at 6:11 PM, Chris Rebert wrote:
> On Thu, Aug 5, 2010 at 8:56 AM, Roald de Vries <downaold at gmail.com>  
> wrote:
>> 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'.
>
> Absolutely incorrect. Read the final paragraph of
> http://docs.python.org/reference/expressions.html#notin

Oops, sorry :$.




More information about the Python-list mailing list