S
Steve Holden
James said:Bart said: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 is created and now
a points to that because += has assignment buried in it.
This is the difference between mutable and immutable types.
>>> a = 5
>>> b = a
>>> a += 1
>>> a 6
>>> b 5
>>> a = [1,2,3,4,5]
>>> b = a
>>> a += [6,7,8]
>>> a [1, 2, 3, 4, 5, 6, 7, 8]
>>> b [1, 2, 3, 4, 5, 6, 7, 8]
>>>
regards
Steve