The unPEP: List-Tuple Unification
Raymond Hettinger
othello at javanet.com
Fri Jul 20 13:27:58 EDT 2001
It looks like types and classes are heading toward unification in 2.2a (oh yeah).
Now, I want to offer an idea that is sure to attract a few flames:
1. Give lists an assignable property called 'immutable' which defaults to zero.
2. If the property gets set to one (i.e. mylist.immutable=1), then the list
disables future assignments. For example, mylist[3]='three' generates:
TypeError: object doesn't support item assignment
3. Immutable lists can never be converted back to mutable. For example,
mylist.immutable=0 generates:
TypeError: immutable objects cannot be changed
4. Immutable lists can be copied to mutable lists just like tuples can. For
example, mynewlist=list(mylist) makes a new mutable list.
5. If a list is used as a dictionary key, then the immutable property
gets set to one automatically.
6. Deprecate tuples. Simplify the tutorials. Get on with life.
Hiding behind asbestos,
Raymond
More information about the Python-list
mailing list