From: <ma...@la...> - 2001-02-23 16:06:46
|
D-Man <ds...@ri...> said: > On Fri, Feb 23, 2001 at 12:42:08PM +0000, ma...@la... wrote: > | Adam Burke <ada...@gb...> said: > | > | > If you want to keep the unsorted data you need to take a copy, ie, y = x. > | > | Careful: y = x doesn't make a copy, it just assigns another > | name for the same list. Use y = x[:] to make a copy. > > That is only a shallow copy. If you modify the objects in list 'y' > afterwards, list 'x' will see the change. If you want a deep copy, > there is a module, "copy" I believe, to handle that. copy.deepcopy(x), yes. For the example given, a shallow copy would suffice, but in the general case, the above observation is pertinent. Mats |