Re: That might be the case for more complex objects...

2007-04-15 Thread Steve Holden
James Stroud wrote: > Bart Willems wrote: >> Dennis Lee Bieber wrote: [...] >> 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. > > I think that after a += 1, a memory location with a 6

Re: That might be the case for more complex objects...

2007-04-14 Thread Steven D'Aprano
On Sat, 14 Apr 2007 16:03:03 -0400, Bart Willems wrote: > 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. This is what you are i

Re: That might be the case for more complex objects...

2007-04-14 Thread DillonCo
On Saturday 14 April 2007, James Stroud wrote: > I think that after a += 1, a memory location with a 6 is created and now > a points to that because += has assignment buried in it. Bingo. a+=1 will (basically) translate to either "a=a.__iadd__(1)" or "a=a.__add__(1)" depending on whether __ia

Re: That might be the case for more complex objects...

2007-04-14 Thread Bjoern Schliessmann
Bart Willems wrote: > 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, They do: >>> a = 5 >>> b = a >>> a is b True >>> a += 1 >>> a is b False ... but not after a is rebound to a n

Re: That might be the case for more complex objects...

2007-04-14 Thread James Stroud
Bart Willems wrote: > 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 sto