On 11/2/2010 3:12 AM, Lawrence D'Oliveiro wrote:
"Immutable objects" are just those without an obvious API for modifying them.
After initial creation ;-)/
They are ones with NO legal language constructs for modifying them.
Suppose I write an nasty C extension that mutates tuples. What then would be illegal about
import tuple_mutator t = (1,2) tuple_mutator.inc(t) t # (2,3) > Hint: if
a selector of some part of such an object were to occur on the LHS of an assignment, and that would raise an error, then the object is immutable.
I am not sure what you are saying here, and how it applies to >>> lt = [(0,)] >>> lt[0][0] = 1 Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> lt[0][0] = 1 TypeError: 'tuple' object does not support item assignment >>> tl = ([0],) >>> tl[0][0] = 1 >>> tl ([1],) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list