Clarification on Immutability please

Michael Torrie torriem at gmail.com
Tue Jan 21 13:55:11 EST 2020


On 1/21/20 11:38 AM, Chris Angelico wrote:
> Are you sure that it does? I can't reproduce this. When you slice the
> first two from a tuple, you create a new tuple, and until the
> assignment happens, both the new one and the original coexist, which
> means they MUST have unique IDs.

And furthermore this has nothing to do with immutability. Slicing
returns a new object whether one is slicing a tuple, list, or a string,
the latter two are mutable objects.


More information about the Python-list mailing list