[Tutor] Best method for filtering lists in lists...
Luke Paireepinart
rabidpoobear at gmail.com
Sat Dec 16 18:01:53 CET 2006
Roel Schroeven wrote:
> Alan Gauld schreef:
>
>> "Chris Hengge" <pyro9219 at gmail.com> wrote
>>
>>
>>> I'm terming a redundant list just like I posted in the original
>>> message:
>>> [[1,2,3], [4,5,6],[1,2,3]]
>>>
>>> [0][0] and [0][2] are redundant, so I only want to keep one of them.
>>>
>> In that case put the inner lists in a Set. That will eliminate
>> duplicates.
>>
>
> That won't work: list objects are unhashable so you can't put them in a
> set. You'll have to convert them to tuples first.
>
>
Ooh.... The plot thickens...
surely there's a faster way than casting them all as tuples, generating
a set, and then casting them all back to lists?
Or perhaps Chris can just keep them as tuples?
More information about the Tutor
mailing list