I was just reading about the "unexpected result of the statement-operator", which is due to the fact that the Python cache numbers are from -5 to 256.
This has been discussed here: the "is" operator behaves unexpectedly with integers
and here: "is" and "id" in Python 3.5
When I run one of the examples here, I get different results between the Python Idle and the Python IDE (I use Jetbrains Pycharm professional edition - 5.0.4).
When using Python IDLE, this is the result:
a = 1000 b = 1000 print (a is b)
when using Pycharm 5.0.4 this is the result:
a = 1000 b = 1000 print (a is b)
how could this be? I double-checked, and my Python-Interpreter project is exactly the same in both cases (both Python 3.5.1). Not sure if this is what I did wrong, and I was hoping if anyone could explain it.
Edit:
I know that 'a' is 'b' == true iff id (a) == id (b), and you can check it, as some of you mentioned in the comments. Perhaps I should have been more clear that I do not understand, so it could be that the IDE has a different behavior? I thought (and please correct me, it seems to me that I am mistaken) that the IDE is just a user-friendly environment that uses external compilers / interpreters, and that is why they are not dependent on these IDEs (for example, support pycharm is not only Python, and I could run Eclipse with a C or Java compiler, etc. (all of which are not part of the IDE).
Thanks, Alon.
Alonbs
source share