On Sep 19, 1:59 am, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > On Sep 18, 5:39 pm, sapsi <[EMAIL PROTECTED]> wrote: > > > I recently tried using the set function in Python and was surprised to > > find that > > > a=[ 1, 2,3, [1,2] ] > > > doesn't work with 'set', throwing TyperError (unhashable exception). I > > found out that this is because lists can't be hashed. > > So,this implies 'a' cannot be a set in python which i think is quite > > unfortunate, after all 'a' does look like a mathematical set. > > This is written as: > > a = set([1, 2, 3, frozenset([1, 2])]) > > > This is not related, but is there i neat way (without pop and list > > comprehension) to convert a set into a list? > > list(a) > > Raymond
frozenset over turning the embedded list into a tuple? The tuple would preserve order in the item (1,2) a = set([1,2,3, (1,2)]) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list