Is vs is equal to (==)?


#1

Simple question here. I’ve been tearing through this awesome game the past few days, so let me just say thanks and keep up the good work! Anyways:

What is the difference between:

if enemy.type == “burl”

vs

if enemy.type is “burl”

They seem to both do the same thing, so i’m just looking for a more thorough understanding. Thanks!


#2

Apparently there’s a difference:
http://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is-in-python


#3

One more as additional for the @zuf’s answer.
For Python2:

"word"  == u"word" # True
"word" is u"word" # True

It can get really surprising results if you are using is instead == for the real software (backend web server for example). I prefer to use ==. Only one exception when I need to check that a variable is None.