Tuples and immutability
Roy Smith
roy at panix.com
Fri Mar 7 08:37:52 EST 2014
In article <XnsA2E95FA1E1EB6duncanbooth at 127.0.0.1>,
Duncan Booth <duncan.booth at invalid.invalid> wrote:
> Is there any reason why tuples need to throw an exception on assigning to
> the element if the old value and new value are the same object?
>
> If I say:
>
> a = ("spam", [10, 30], "eggs")
>
> then
>
> a[0] = a[0]
>
> won't actually mutate the object. So tuples could let that silently pass.
But, why would you want them to? What a way to introduce bugs which are
difficult to test for.
More information about the Python-list
mailing list