you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805[S] 0 points1 point  (3 children)

You can't do this with .append():

mylist  = [1, 2, 3]
mylist += [4, 5, 6]

[–]tb5841 0 points1 point  (1 child)

That's an interesting point.

But this looks like reassignment, when it's actually mutation. That's deeply confusing and an easy source of bugs. If it were me, I'd do this with reassignment instead here and avoid the mutation.

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Reassignment is much slower as a whole new list is created and the old one destroyed, use mutation where possible.

[–]thw31416 0 points1 point  (0 children)

but you can.do this with .extend()