Python – unpack list of lists

Question:

What is the cleanest way to implement the following:

list = [list1, list2, ...]
return [*list1, *list2, ...]

It looks like this syntax will be available in Python 3.5. In the meantime, what is your solution?

Asked By: Eric Kaschalk

||

Answers:

This is commonly written as:

[x for l in list for x in l]
Answered By: Lynn
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.