convert list of lists to list
Raymond Hettinger
python at rcn.com
Tue Jul 22 12:21:36 EDT 2008
On Jul 22, 8:25 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> if there's only one level of recursion, and the lists aren't too long,
> you can simply do:
>
> sum(list_of_lists, [])
>
> (this has quadratic performance, so don't use it for large structures)
For linear performance, you can use itertools:
list(itertools.chain(*list_of_lists))
Raymond
More information about the Python-list
mailing list