cyclic data structures
Duncan Booth
duncan.booth at invalid.invalid
Mon Feb 13 16:25:35 EST 2006
John Salerno wrote:
> L.append(L) basically creates this, I think:
>
> [1, 2, L]
Correct.
>
> Now, assuming that's correct, and since L points to the list [1, 2],
wrong. You just said it yourself: L is now the list [1, 2, L]
> why
> can't '[1, 2]' be substituted for the 'L' and then the list is closed?
>
The append method modifies the list in place. The list which contained 1,2
now has a third element which is a reference to itself.
More information about the Python-list
mailing list