Question on lists

Matteo Dell'Amico della at toglimi.linux.it
Wed Jul 28 05:08:14 EDT 2004


Andrew Bennetts wrote:

> Nothing builtin that I know of, but it's trivial to write:

Using 2.4, looks like the logic is in itertools.groupby:

 >>> from itertools import groupby
 >>> l = ['a', 'b', 'c', 'c', 'd', 'd', 'd', 'e']
 >>> list(x for x, _ in itertools.groupby(l))
['a', 'b', 'c', 'd', 'e']

-- 
Ciao,
Matteo



More information about the Python-list mailing list