Recursive list comprehension

Timothy Babytch tim at zeos.net
Mon Dec 6 10:26:07 CET 2004


Hi all.

I have a list that looks like [['N', 'F'], ['E'], ['D']]
I try to make it flat one: ['N', 'F', 'E', 'D']

How can I archieve such an effect with list comprehension?
Two cycles did the job, but that way did not look pythonic..

I tried
print [x for x in y for y in c_vars]
and got NameError: name 'y' is not defined.

-- 
Timothy Babytch



More information about the Python-list mailing list