I want to show someone how using is
instead of ==
to compare integers can fail. I thought this would work, but it didn't:
>>> import copy
>>> x = 1
>>> y = copy.deepcopy(x)
>>> x is y
True
I can do this easily for bigger integers:
>>> x = 500
>>> y = 500
>>> x is y
False
How can I demonstrate the same thing with smaller integers which might typically be used for enum-like purposes in python?