list of lists?? please help
David Goodger
dgoodger at bigfoot.com
Wed Sep 27 23:13:14 EDT 2000
on 2000-09-26 22:23, Tom Kerrigan (Thomas.Kerrigan at Colorado.EDU) wrote:
> I have two lists, state and node. I want node to be a list of states. State
> is a list itself. The problem is that when I try to add state to node, e.g.,
>
> node.append(state)
>
> it only adds a pointer to state. This defeats my goal, because I just end up
> with a list containing the same thing over and over.
So you want to add a *copy* of state to node? Do:
node.append(state[:])
You'll get the same thing over and over, as before, but each state is
independently modifiable now.
--
David Goodger dgoodger at bigfoot.com Open-source projects:
- The Go Tools Project: http://gotools.sourceforge.net
(more to come!)
More information about the Python-list
mailing list