Python 3.0 - is this true?

"Martin v. Löwis" martin at
Mon Nov 10 10:10:19 CET 2008

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.


More information about the Python-list mailing list