How is `var[:] = []` different from `var = []`?

The assignment var = [] binds the name var to the newly created list. The name var may or may not have been previously bound to any other list, and if it has, that list will remain unchanged.

On the other hand, var[:] = [] expects var to be already bound to a list, and that list is changed in-place.

That's why the behaviour in these two cases is different:

var1 = [1, 2, 3]
var2 = var1
var1 = []
print(var1, var2)  # prints [] [1, 2, 3]

var1 = [1, 2, 3]
var2 = var1
var1[:] = []
print(var1, var2)  # prints [] []

This code demonstrates what is going on:

original = ['a','b','c']

letters = original

print('Same List')
print(original)
print(letters)

letters = []

print('Different lists')
print(original)
print(letters)

letters = original

letters[:] = []

print('Same list, but empty')
print(original)
print(letters)

Output:

Same List
['a', 'b', 'c']
['a', 'b', 'c']
Different lists
['a', 'b', 'c']
[]
Same list, but empty
[]
[]

The first part of the code: letters = original means that both variables refer to the same list.

The second part: letters = [] shows that the two variables now refer to different lists.

The third part: letters = original; letters[:] = [] starts with both variables referring to the same list again, but then the list itself is modified (using [:]) and both variables still refer to the same, but now modified list.