|
It's not pretty, but you can do it: >>> sum([['a', 'b', 'c'], ['d', 'e', 'f']], [])
['a', 'b', 'c', 'd', 'e', 'f']
This makes use of the optional start argument and list add operator. However, Python's docs suggest using itertools.chain instead:http://docs.python.org/library/functions.html#sum >>> import itertools
>>> [l for l in itertools.chain(*[['a', 'b', 'c'], ['d', 'e', 'f']])]
['a', 'b', 'c', 'd', 'e', 'f']
(Of course you lose the benefit of a generator by using a list comprehension, but this is just an example.) |