disadvantage of python deepcopy
a = [(3,obj1),(4,8)]
b = deepcopy(a)
In some case we cant take deepcopy of some objects in a list.
In that case use list comprehension to make a deep copy of that list.
b = [x for x in a]
---------------------
a = [(3,obj1),(4,8)]
b = copy.deepcopy(a)
Traceback (most recent call last):
b = copy.deepcopy(a)
File "/usr/lib/python2.4/copy.py", line 204, in deepcopy
y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.4/copy.py", line 351, in _reconstruct
state = deepcopy(state, memo)
File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
y = copier(x, memo)
File "/usr/lib/python2.4/copy.py", line 268, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.4/copy.py", line 174, in deepcopy
y = copier(x, memo)
File "/usr/lib/python2.4/copy.py", line 292, in _deepcopy_inst
return x.__deepcopy__(memo)
TypeError: 'NoneType' object is not callable
----------------------------
No comments:
Post a Comment