hi i have a situation like this:
>>> def get():
... for i in range(3):
... yield [0]
...
and i want to get this: [0,0,0]
my code now works in this way:
>>> r = []
>>> r.extend(i[0] for i in get())
>>> r
[0, 0, 0]
but i don’t like i[0]..
some advice?
(i’m on python3)
This kind of imperative code (stateful, with inplace updates) is asking for trouble. That seems the canonical use for a functional flatten (concat):