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?

1
  • "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. Commented May 25, 2022 at 22:31

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.