The second [:], on the right side, is redundant. It simply copies dabefore using it in concatenation, which is pointless.
Left:
a[:] += da
First, let's understand what it does a += da. It displays:
a = a.__iadd__(da)
The call __iadd__extends the original list aand returns self, that is, a link to the list. Thus, the assignment that occurs after this has no effect in this case (same as a=a).
This achieves the original goal, i.e. to expand the global array.
Now what does a[:] += da? It displays:
a[:] = a[:].__iadd__(da)
Or more tiring:
a.__setitem__(slice(None), a.__getitem__(slice(None)).__iadd__(da))
For readability, write it as (not valid python syntax):
a.__setitem__(:, a.__getitem__(:).__iadd__(da))
So a[:].__iadd__(da):
- creates a copy
a(call a2) da a2- return
a2
a[:] = ...:
a a2 .
, , , - .
.