I came across an expression in one of the pyqtgraph examples which I don't quite understand.
spots = [{'pos': pos[:,i], 'data': 1} for i in range(n)] + [{'pos': [0,0], 'data': 1}]
In the example pos
is a two-dimensional NumPy array and n
a positive integer.
What exactly is the for
statement doing in inside an expression?
Also, I might need an explanation for pos[:,i]
.
Lastly, how exactly does the +
operator work with lists? Does it just merge them like list.extend(anotherlist)
?