[issue40565] is comparison returns False while ids are the same.

Eric V. Smith report at bugs.python.org
Fri May 8 12:21:11 EDT 2020


Eric V. Smith <eric at trueblade.com> added the comment:

This isn't doing what you think. Because you throw away the object after computing its id, the same memory is reused and you get the same id.  Consider:

>>> a = [1,2,3]
>>> b = [3,4,5]
>>> id(a[:]) == id(b[:])
True

There's no problem here, but it does show that you need to be careful with "is" and "id".

----------
nosy: +eric.smith
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40565>
_______________________________________


More information about the Python-bugs-list mailing list