PyCharm and Python's id() function
已回答
Simple code run in PyCharm and in a terminal:
Terminal:
>>> a = 500
>>> b = 500
>>> print(id(a))
139745079475248
>>> print(id(b))
139745079475408
PyCharm:
print(id(a))
139708112895280
print(id(b))
139708112895280
Using Python 3.6. So in PyCharm objects with values greater than 256 have the same ID.
a is b in PyCharm reports True. In the terminal it's False.
I'm probably missing something here so i'd be grateful if someone can shine some light. Thanks!
请先登录再写评论。
Hi,
If you run this as a script in the system terminal, then you will have the same result, which means that it is not related to PyCharm.