I want to show someone how using is instead of == to compare integers can fail. I thought this would work, but it didn\'t:
is
==
>>
You can do:
>>> 0 - 6 is -6 False >>> 0 - 6 == -6 True
It also works for bigger numbers:
>>> 1000 + 1 is 1001 False >>> 1000 + 1 == 1001 True
It depends on what you want to demonstrate but the above highlights the difference in functionality between is and ==.