Tuple Format?

Delaney, Timothy tdelaney at avaya.com
Tue Sep 5 06:59:55 EDT 2000


I do like the idea of adding constness (I prefer the term immutability) in a
general way to objects. This would enforce that only __getattr__,
__getslice__ etc could be called. There could be no assignment to instance
properties. etc etc etc ... sorry - bit slow right now ... just finished a
13-hour day on 3 hours sleep.

> Why use tuples at all?  The Pythonic way to enforce usage 
> restrictions is
> through convention:
> 
> a = [1, 2, 3] # Do not modify this object!
> 
> Another, more general way of dealing with mutable/immutable 
> objects would be
> to introduce the concept of const references:
> 
> a = [1, 2, 3]
> print isconst(a) # Prints 0
> b = const(a)
> print isconst(a) # Prints 0
> print isconst(b) # Prints 1




More information about the Python-list mailing list