Data structure and algorithms
Diez B. Roggisch
deets at nospam.web.de
Mon Jan 29 02:51:13 EST 2007
azrael schrieb:
> i'd like to get more control like in c with pointers. I want to loose
> the data after disabling:
>
>>>> list=[]
>>>> list.append(Node(1))
>>>> list.append(Node(2))
>>>> list[0].next=list[1]
>
>
> 1, 2
>
>
>>>> list.append(Node(3))
>>>> list[1].next=list[2]
>
>
> 1,2,3
>
>
>>>> list[0].next=list[2]
>
> 1,3 (but 2 still exists as list[2])
So what? Then do
del list[2]
This is what happens in C also - if you store references to structures,
they don't magically go away just because you refer to them from other
places.
Diez
More information about the Python-list
mailing list