0
a = 1000
b = 1000
a is b

So if you run this code using pycharm or command python filename.py a is b = True If you run this code using command line a is b = Fasle. I know about implemented array in python (-5 .. 256), but the question is why it's True when you run your code not from command line?

chydik
  • 1,037
  • 1
  • 7
  • 5
  • "but the question is why it's True when you run your code not from command line?" Nothing is guaranteed by the specification, and there is no reason to care about the behaviour from a code correctness perspective. – Karl Knechtel May 25 '22 at 22:31

1 Answers1

0

Normally, a is b checks if both variables refer to the same object. And a == b checks for equality of their values. However, that might not be the case in python for small integers. Look at this reddit post with similar question to get more info.

WithThee
  • 79
  • 4