Howto: extract a 'column' from a list of lists into a new list?

Greg Brunet gregbrunet at NOSPAMsempersoft.com
Tue Jul 1 04:22:05 CEST 2003


"Egor Bolonev" <ebolonev at rol.ru> wrote in message
news:bdqp9e$7r$1 at news.rol.ru...

> =============================================
> a=[('STOCKNO', 'C', 8, 0), ('DACC', 'C', 5, 0), ('DEALERACCE', 'C',
30,
> 0), ('D-ACCRTL', 'C', 9, 0), ('D-ACCCST', 'C', 9, 0)]
>
> b=[x[0] for x in a]         # :-) Python is cool!
>
> print b
> =============================================
>
> As I know the map/lamda/list works very slow and you should use it
'only'
> with SCRIPTS.

Thanks Egor!

It looks like I was closer than I thought - but still would have been
unlikely to figure it out!

-- 
Greg





More information about the Python-list mailing list