-1

Hello I am new to python. Does Python IDLE and Pycharm handle is and == statements differently? In Python IDLE I get false for the statement apple is orange and in PyCharm it seems to return true.

I had set both apple = 500 and orange = 500. In python IDLE I got false for apple is orange, as I had expected, since they are different objects. I got true for apple == orange since both are equal to 500. In Pycharm community edition I set up if statements to test the same statements and I got true for both.

Unfortunately I can not upload a screenshot due to my reputation not being 10.

Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
r6180
  • 1
  • 1
  • It's not a PyCharm problem, it's a semantic difference. – Stefano Sanfilippo Oct 19 '14 at 16:12
  • possible duplicate of [Why does comparing strings in Python using either '==' or 'is' sometimes produce a different result?](http://stackoverflow.com/questions/1504717/why-does-comparing-strings-in-python-using-either-or-is-sometimes-produce) – Stefano Sanfilippo Oct 19 '14 at 16:12

1 Answers1

0

Do not use is unless you know what you are doing. If a is b, then a points to exact same memory address as b. ==, on the other hand, implements the expected concept of equality.

Joshua
  • 2,431
  • 15
  • 23