On Mon, 2006-02-13 at 16:03, John Salerno wrote: > 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?
L is [1,2] before the append. After the append, L is [1,2,L], which is [1,2,[1,2,L]], which is [1,2,[1,2,[1,2,L]]] etc into infinity. L literally contains itself after the append. HTH, Carsten. -- http://mail.python.org/mailman/listinfo/python-list