([ 'ni' ]{' ' ' ''spam'' ' }in terms of our original exampleyou can avoid the reference side effects by slicing the original list instead of simply naming itx [ [' ' [:]' ' {' ': [:]' ': embed copies of ' object this changes the picture in figure - -- and will now point to different lists than the net effect is that changes made through will impact only xnot and dsimilarlychanges to or will not impact one final note on copiesempty-limit slices and the dictionary copy method only make top-level copiesthat isthey do not copy nested data structuresif any are present if you need completefully independent copy of deeply nested data structure (like the various record structures we've coded in recent )use the standard copy moduleintroduced in import copy copy deepcopy(yfully copy an arbitrarily nested object this call recursively traverses objects to copy all their parts this is much more rare casethoughwhich is why you have to say more to use this scheme references are usually what you will wantwhen they are notslices and copy methods are usually as much copying as you'll need to do comparisonsequalityand truth all python objects also respond to comparisonstests for equalityrelative magnitudeand so on python comparisons always inspect all parts of compound objects until result can be determined in factwhen nested objects are presentpython automatically traverses data structures to apply comparisons from left to rightand as deeply as needed the first difference found along the way determines the comparison result this is sometimes called recursive comparison--the same comparison requested on the top-level objects is applied to each of the nested objectsand to each of their nested objectsand so onuntil result is found later in this book--in --we'll see how to write recursive functions of our own that work similarly on nested structures for nowthink about comparing all the linked pages at two websites if you want metaphor for such structuresand reason for writing recursive functions to process them in terms of core typesthe recursion is automatic for instancea comparison of list objects compares all their components automatically until mismatch is found or the end is reachedl [ (' ' ) [ (' ' )same valueunique objects tuplesfilesand everything else