frozenset question

Qiangning Hong hongqn at gmail.com
Wed Jul 6 06:08:08 EDT 2005


On 7/6/05, Will McGugan <news at nowillmcguganspam.com> wrote:
> Hi,
> 
> Are there any benefits in using a frozenset over a set, other than it
> being immutable?

A frozenset can be used as a key of a dict:

.>> s1 = set([1])
.>> s2 = frozenset([2])
.>> {s1: 1}
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: set objects are unhashable
.>> {s2:1}
{frozenset([2]): 1}

-- 
Qiangning Hong
Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1>



More information about the Python-list mailing list