Recursive list comprehension

Nick Coghlan ncoghlan at
Mon Dec 6 13:04:12 CET 2004

Peter Otten wrote:
> Nick Coghlan wrote:
>>from itertools import chain
>>n = [['N', 'F'], ['E'], ['D']]
>>print [chain(*n)]
> However, [generator] is not the same as list(generator):

Heh - good point. As you say, replacing with list() gives the intended answer.

With regards to laziness, my main point was that itertools is handy for 
manipulating sequences, even if you aren't exploiting its capacity for lazy 


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list