I'm wondering why this evaluates to True
.
x = 1
if x is 1:
print "Does x and 1 point to the same object?"
print "Does this mean python doesn't store redundant values?"
It doesn't work for this case as I expect.
x = range(10)
y = range(10)
if not x is y:
print "I expect this"
My understanding is that is
checks to see if two names are pointing to the same object. Does this imply that python has a mechanism to avoid creating redundant values?