copy.deepcopy() function : copy « Buildin Module « Python Tutorial






person = ['name', ['savings', 100.00]]
personClone = person

import copy
personDup = copy.deepcopy(person)
print [id(x) for x in person, personClone, personDup]
personClone[0] = 'joe'
personDup[0] = 'jane'
print personClone, personDup
personClone[1][1] = 50.00
print personClone, personDup








14.2.copy
14.2.1.make a deep copy, copying the values, any values they contain
14.2.2.copy.deepcopy() function