0

Here is my Python2 script, test.py:

x = sys.argv[1]
y = 'foo'
print(x)
print(y)
print(x is y)

I then call my script with python test.py 'foo'. This prints out:

foo
foo
False

But both x and y appear to be the same value, 'foo'. So why is this equivalence test returning False?

Karnivaurus
  • 22,823
  • 57
  • 147
  • 247

1 Answers1

1

You need to use ==

is will return True if two variables point to the same object, == if the objects referred to by the variables are equal.

Robin
  • 191
  • 8