I'm still confused by this oddity, originally posted by @driscollis:

x = True
y = False
print(x is (not y))
print(not x is y)
print(not (x is y))
print((not x) is y)
print(x is not y)
print(x == (not y))
print(not x == y)
print(not (x == y))
print((not x) == y)
print(x == not y)

Why is the last line a syntax error when the rest are fine?

@peterdrake @driscollis I don't do Python, butt maybe a the ( ) missing around not

@sassdawe @driscollis I could understand an "operator precedence" issue being solved with parentheses, but something like x == !y works fine in other languages. Also, why does "x is not y" work but "x == not y" doesn't? I would expect is and == to be syntactically interchangeable.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.