How to convert list of tuples into a single list of unique values ?
Hendrik Reichel
cynamite at gmx.net
Fri Jan 11 16:36:58 EST 2002
Skip Montanaro wrote:
> I was originally thinking of using a single for
> loop and flattening the tuples:
>
> P = []
> [P.extend(list(t)) for t in L]
from operator import add
P = list(reduce(add, L))
seems like a cleaner and faster way to achieve this goal,
avoiding building up an unused list of [None, None, ...].
(Just in case someone's copy&pasting the code ;-)
More information about the Python-list
mailing list