Recursive list comprehension
Nick Coghlan
ncoghlan at iinet.net.au
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
evaluation.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
More information about the Python-list
mailing list