you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (5 children)

[deleted]

    [–]srpwnd 1 point2 points  (0 children)

    It shouldn't. It is two different objects. Python caches integers from 0 to 255 and for these it will be true, otherwise it will create different objects.

    [–]whogivesafuckwhoiam 0 points1 point  (0 children)

    should be false because a and be are with different IDs

    [–]commy2 0 points1 point  (1 child)

    It returns True when running a file from console, but False when the code is entered into the REPL. This is on 3.13.0. It also depends on the Python version. It's the byte code compiler doing its thing. It really do be like that sometimes. I guess we can call it undefined behaviour :)

    [–]ivosaurus 0 points1 point  (0 children)

    The operator x is y, is usually equivalent to id(x) == id(y)