sturlamolden wrote:
What happens here? Does Python (2.6.5) have an "is not" operator?
a = 5
print (a is not False)
True
print (a is (not False))
False
print (not (a is False))
True
It seems "y is not x" fits well with spoken English, but it is also a
bit surprising that "y is not x" does not mean "y is (not x)" but "not
(y is x)". Why does Python reorder is and not operators, and what are
the formal rules for this behavior?
In English the negative comes after the verb (or the auxiliary, if there
is one), so:
x is not y
If you wanted to abbreviate:
x is in y
the natural result would be:
x in y
and the opposite:
x is not in y:
would be abbreviated to:
x not in y
The resulting inconsistency in Python is somewhat unfortunate, but in
practice it's not a problem because:
not y
returns either False or True, and how often would you write:
x is False
or:
x is True
?
--
http://mail.python.org/mailman/listinfo/python-list