C. · @cazabon
169 followers · 4177 posts · Server mindly.social

@matt

Oh, and sets too.

Example with shallow list copy and an embedded mutable object (another list):

>>> a = [1, 2, [3, 4]]
>>> b = a.copy()

>>> b
[1, 2, [3, 4]]
>>> b[0] = 5
>>> b
[5, 2, [3, 4]]

>>> a
[1, 2, [3, 4]]

>>> b[2][0] = 8
>>> a
[1, 2, [8, 4]]
>>> b
[5, 2, [8, 4]]

#mutability #copy #whotouchedmy

Last updated 2 years ago