I come across some great questions and answers about copying lists by reference vs by value (this, this and this). Unfortunately, none of proposed solutions removes the reference from all the nested structures (tried b = a[:]
, b = list(a)
, copy.copy
...). My last hope was copy.deepcopy
but it doesn't work for nested structures when there is an array somewhere inside (I am working on openpyxl columns). I get this error on the bottom of the stack:
File "C:\Python27\lib\copy.py", line 257, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
TypeError: unhashable type: 'array.array'
My question is: is it possible to create a full copy of list a
without any references, regardless of what is nested inside a
?