From my understanding, if a variable of an immutable type is assigned a value equal to another variable of the same immutable type, they should both refer to the same object. I am using Python 2.7.6, I do not know if this is a bug.
This behaves as I understood:
x = 'ab' y = 'ab' id(x) == id(y) True
However, changing the symbol does not behave:
x = 'a#' y = 'a#' id(x) == id(y) False
Strange though concurrent assignment is very different!
x, y = 'a#','a#' id(x) == id(y) True
I do not understand this behavior.
ewong718
source share