Why don't I get an error for this?

I wasn’t too sure where to stick this, but I thought this would be the best place.

Too many times now, I’ve made a mistake like this:

#this is what I wanted
x = y
#this is what I typed
x == y

Why does this not bring up an error in the console? I mean, it’s basically a single line with a 0 or a 1 on it. Shouldn’t that be a syntax error?

Well, if x and y are defined already, you should get no errors from that expression. If x hasn’t been defined and you still don’t get an error message, well…I don’t know, really :slight_smile:

That’s very strange. I have a feeling though, that “this might in fact be intended behaviour”.

With
x = y
you are assigning the value of y to x

With
x == y
you are testing whether x equals y?
But when it appears on a line of its own, the outcome of this test is ignored, and no action is taken.

Both Python 2.3 and Python 2.4 do this.

Aligorith