Paul Rubin wrote: > Fair enough. How's this: > > a = ImmutableObject() > b = deepcopy(a) > assert a == b # a and b start out equal > .... do stuff .... > # since a and b are immutable, they should still be equal > # no matter what has happened above > assert a == b > > If you've added attributes to a but not to b, they should compare > unequal, breaking immutability.
How about this ? a=(1,[]) b=copy.deepcopy(a) assert a==b # True a[1].append(1) assert a!=b -- http://mail.python.org/mailman/listinfo/python-list