1

Im curious, why does it not equals True in one python version and False in another and vise versa.

big_num_1   = 1000
big_num_2   = 1000
small_num_1 = 1
small_num_2 = 1

print(big_num_1 is big_num_2) # python2 output True; python3 output False
print(small_num_1 is small_num_2) # python2 output False; python3 output True

funny thing is my sublime text editor in Python3 does output both as True, where in Terminal it outputs as stated above

nexla
  • 434
  • 7
  • 20
  • 2
    `is` *does not compare objects* - that's what `==` is for. `is` compares *object identities*, which is almost never something you actually care about. – jasonharper Jan 24 '19 at 17:04
  • 2
    see https://stackoverflow.com/questions/306313/is-operator-behaves-unexpectedly-with-integers for a explanation of previous comment – Frayal Jan 24 '19 at 17:05
  • 2
    Output is True for both cases for Python2, Python3 and Python3.6. The reason why your terminal and Sublime outputs are different is because you use different python interpreters. – Filip Młynarski Jan 24 '19 at 17:06

0 Answers0