Copy dict to a new object
1 2 3 4 5 6 7 8 9 10 11 12 13 | def copy_obj(old, excluded_attrs=[]):
'''
Returns a new dict with items for copy to a new object
excluded_attrs is list of attributes that we want to exclude for copy
'''
d = {}
for key, value in old.items():
if(len(excluded_attrs)>0):
if key not in excluded_attrs:
d[key] = value
else:
d[key] = value
return d
|