Addressing the last element of a list
Simon Brunning
simon.brunning at gmail.com
Tue Nov 8 05:01:29 EST 2005
On 8 Nov 2005 01:43:43 -0800, pinkfloydhomer at gmail.com
<pinkfloydhomer at gmail.com> wrote:
> But if lst[42]["pos"] happens to hold an integer value, then
>
> a = lst[42]["pos"]
>
> will _copy_ that integer value into 'a', right?
Nope. It will bind the name 'a' to the integer object.
> Changing 'a' will not
> change the value at lst[42]["pos"]
Integers are immutable - they can't be modified. So, "Changing 'a'"
means binding the name 'a' to a different object. This will have no
effect on other references to the original object.
Reset your brain - <http://effbot.org/zone/python-objects.htm>.
--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/
More information about the Python-list
mailing list