[Tutor] Copy of list
Sean 'Shaleh' Perry
Thu, 08 Feb 2001 09:44:54 -0800 (PST)
> That doesn't work. I understand the problem. The copy is not the data but the
> reference. This
> can be checked with id(mySavedList) which is the same as id(myList). I
> presume, I have to do
> an explicit copy ('deep copy' is the correct name??).
> Does anyknow the correct function of method to do the trick?
>>> import copy
['Error', '_EmptyClass', '__builtins__', '__doc__', '__file__', '__name__',
'_copy_atomic', '_copy_dict', '_copy_dispatch', '_copy_inst', '_copy_list',
'_copy_tuple', '_deepcopy_atomic', '_deepcopy_dict', '_deepcopy_dispatch',
'_deepcopy_inst', '_deepcopy_list', '_deepcopy_tuple', '_keep_alive', '_test',
'copy', 'deepcopy', 'error']
what you want is copy.deepcopy().