after sorted from the lists

Ben Bush pythonnew at gmail.com
Tue Nov 22 11:58:20 EST 2005


On 11/22/05, jepler at unpythonic.net <jepler at unpythonic.net> wrote:
> >>> ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]]
> >>> ls = [frozenset(i) for i in ll]
> >>> ss = set(ls)
> >>> ss
> set([frozenset([1, 3]), frozenset([1, 2]), frozenset([1, 4]), frozenset([3])])
> >>> [list(i) for i in ss]
> [[1, 3], [1, 2], [1, 4], [3]]
why this happens?
>>> from sets import *
>>> ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]]
>>> ls = [frozenset(i) for i in ll]
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
NameError: name 'frozenset' is not defined



More information about the Python-list mailing list