Hi Stan, On Tue, Nov 4, 2008 at 11:51 AM, Stan Schymanski <[EMAIL PROTECTED]> wrote: > Thanks for the clarification. I think I see a bit of a light in the fog. > So since lists and dictionaries are immutable objects, any references to > them must always refer to the same thing.
William had a typo in his email and meant to say that lists and dictionaries are mutable (that is, they can be changed), while symbolic variables can not be changed. > Consequently, if the result of > the reference is to be changed, the object itself has to change. Did I > get this right? I still struggle to understand the difference between > LL=L and LL=2*L. Is there a section in the tutorial or reference that > could help? When you write, L=2, Python first creates a "two object" in memory (which you should think of as a black box) and makes L a reference to that object. When you say LL=L, it says that LL is a reference to the same thing that L is a reference to. When you do LL = 2 * L, Python first computes the right hand side ( 4 ) and stores it in memory. Then, LL becomes a reference to this object. So, when you do, L = [L1, L2] L[0] is really referencing the same object as L1 is referencing. (They both point to the same spot.) When you set L[0][1] = 99, you will see that reflected in L1. Hope that helps, --Mikw --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
