The unPEP: List-Tuple Unification

Steve Holden sholden at holdenweb.com
Fri Jul 20 19:32:20 CEST 2001


"Raymond Hettinger" <othello at javanet.com> wrote in message
news:3B586A1E.B037349D at javanet.com...
> 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,
>
No asbestos required, but what's tha advantage over

    mylist = tuple(mylist)

just-wonderingl-ly y'rs  - steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list