Addressing the last element of a list

bonono at gmail.com bonono at gmail.com
Tue Nov 8 11:17:57 CET 2005


If you want to do what you want(though I don't know why without a
concrete example), just store a mutable object at lst[42]["pos"], like
this :

lst[42]["pos"] = [1]

a = lst[42]["pos"]
a[0] = 2
assert(lst[42]["pos"][0] == 2)

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? Changing 'a' will not
> change the value at lst[42]["pos"]




More information about the Python-list mailing list