Hi, Stan, On Nov 4, 2008, at 00:47 , Stan Schymanski wrote:
> Sorry, I should have looked around a bit more. If I replace pars1 = > pars > by pars1 = pars.copy() in the below code, the two dictionaries are > independent. You found part of the story, but there's a bit more. Consider this example: sage: L1=[1,2,3];L2=[3,4,5] sage: L=[L1,L2] sage: L3=[6,7,8] sage: LL=copy(L) sage: LL[1]=L3 sage: L [[1, 2, 3], [3, 4, 5]] sage: LL [[1, 2, 3], [6, 7, 8]] sage: LL[0][1]=17 sage: LL [[1, 17, 3], [6, 7, 8]] sage: L [[1, 17, 3], [3, 4, 5]] In your example, only the dictionary associations are copied. If one of the values (or keys, FWIW) in one of the entries had deeper structure, that would not get copied (only a pointer would be copied). 'copy()' just copies the "first level"; if you want a copy of the entire object, you need to use 'deepcopy()'. HTH Justin -- Justin C. Walker, Curmudgeon at Large Institute for the Absorption of Federal Funds ----------- Like the ski resort full of girls hunting for husbands and husbands hunting for girls, the situation is not as symmetrical as it might seem. - Alan MacKay -- --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
