Flattening lists

mk mrkafk at gmail.com
Thu Feb 5 11:06:28 EST 2009


Mark Dickinson wrote:
> I often find myself needing a 'concat' method that
> turns a list of lists (or iterable of iterables) into
> a single list;  itertools.chain does this quite nicely.
> But I don't think I've ever encountered a need for the
> full recursive version.


You're most probably right in this; however, my main goal here was 
finding 'more Pythonic' way of doing this and learning this way rather 
than the practical purpose of flattening deeply nested lists.

Regards,
mk




More information about the Python-list mailing list