Dennis Lee Bieber wrote: > On 14 Apr 2007 06:35:34 -0700, "jamadagni" <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > In Python, the "variable" NAME does NOT define storage; unlike most > other classical languages where the "variable name" is a storage > address, and the value of the RHS is COPIED to that address. Python does > not do such copying. Names are references to the RHS object itself. > > a = 5 > > means that somewhere in memory is an integer object with the value "5"; > the name "a" is now "pasted onto" that integer object. > > b = a > > finds the object that has the name "a" stuck to it, and sticks a second > name "b" onto the same object. There is still only one "5" in memory.
I can try this in interactive mode: >>> a = 5 >>> b = a >>> a += 1 >>> print b 5 So, if /a/ and /b/ where pointing to the *same* "5" in memory, then I would expect b to be increased, just as a. But after increasing a, b is still 5... Lists behave as described above, integers and floats don't. By the way, a classic language like C has features like this too; they're called pointers. -- http://mail.python.org/mailman/listinfo/python-list