I have a collection of functions fns
and each function returns a pair of integers [a,b]
. I need to call each function and join the result in one flat list. Without comprehensions, the code would look like this:
res = []
for fn in fns:
res += fn()
return res
The question is, can I write this as a oneliner? I had high hopes with [*fn() for fn in fns]
, however Python unfortunately does not understand the unpack operator here and throws a syntax error.