How to convert list of tuples into a single list of unique values ?
Alex Martelli
aleax at aleax.it
Thu Jan 10 11:28:19 EST 2002
"Paul Rubin" <phr-n2002a at nightsong.com> wrote in message
news:7x4rludzwn.fsf at ruckus.brouhaha.com...
> pekka niiranen <krissepu at vip.fi> writes:
> > I have a list of equal size tuples, but a tuple may contain empty
values:
> >
> > t = [ ( a,b,c), (d, ,f) (b,a,j) ]
> >
> > How can I convert it into a single list of unique values:
******
> >
> > l = [a,b,c,d,f,j]
> >
> > No lambdas, please
>
> I don't think (d, ,f) is syntactically valid. Other than that,
> is something wrong with
> import operator
> l = operator.add(*t)
This doesn't answer the "unique" specification (in the example, items
b and a occur in the last tuple, but not in the result as they would
not be unique).
Alex
More information about the Python-list
mailing list