Closed xinan closed 3 years ago
gdb spits SyntaxWarning: "is" with a literal. Did you mean "=="? on startup.
gdb
SyntaxWarning: "is" with a literal. Did you mean "=="?
Generally == should be used unless we are trying to check if both sides are the same object.
==
x is 3 works because Python stores small integers at a fixed address. It won't work as intended if the literal is large. For example:
x is 3
> x = 300 > x is 300 False
gdb
spitsSyntaxWarning: "is" with a literal. Did you mean "=="?
on startup.Generally
==
should be used unless we are trying to check if both sides are the same object.x is 3
works because Python stores small integers at a fixed address. It won't work as intended if the literal is large. For example: