Notice that if you negate a boolean value with not in comparison with other boolean value or similar, you should put it inside a pair of parenthesis, otherwise you get syntax error:

>>> 0 == not 1
SyntaxError: invalid syntax
>>> 0 == (not 1)
True
>>> 

Looks like the interpreter evaluates 0 == not

The interpreter only obeys python's grammar which says that both sides of a comparison operator must be "or_expr"s (one of python's syntactic categories). An expression like not ... can not be considered an or_expr. With parenthesis, it becomes an "atom", which can be considered as an "or_expr".
Grammar is a cold mechanism, don't think python does anything clever here :)

not is expression operator, and there can not also be applied type operators, even it is like function

>>> type(not)
SyntaxError: invalid syntax
>>> type(+)
SyntaxError: invalid syntax
>>> True == --1
True
>>> def not_(e):
    return not e

>>> type(not_)
<type 'function'>
>>> 0 == not_(1)
True

print(not None)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.