On Nov 10, 4:10 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: > > Your > > choice of containers is not based on any theoretical arguments of what each > > type was intended to represent, but the cold hard reality of what > > operations they support. > > Right. What seems missing is a "frozen list" type - the list needs to be > frozen in order to be used as a dictionary key (or any other lookup > structure). Fortunately, as you say, tuples already fill that role, so > one could write > > frozenlist = tuple > ... > sequence = frozenlist(items) > d[sequence] = d.get(sequence,0)+1 > > to make it explicit that here, the tuple has a different role.
If list grew a frozenlist superclass (just move up all the non- mutating methods of list) and had a new freeze method, there would be no need to copy the sequence: def freeze(self): self.__class__ = frozenlist George -- http://mail.python.org/mailman/listinfo/python-list