cyclic data structures

John Salerno johnjsal at NOSPAMgmail.com
Mon Feb 13 16:03:07 EST 2006


Peter Decker wrote:

> 'L' is a pointer to a list. You are now adding that pointer to the
> very list it points to.

I understand that, but I guess I just don't see how this creates 
anything other than a list that refers to [1, 2], and then refers again 
to [1, 2], to create [1, 2, [1, 2]].

L.append(L) basically creates this, I think:

[1, 2, L]

Now, assuming that's correct, and since L points to the list [1, 2], why 
can't '[1, 2]' be substituted for the 'L' and then the list is closed?



More information about the Python-list mailing list