Syntax: pointers versus value
Tino Lange
tl_news at nexgo.de
Wed Jul 30 13:03:49 EDT 2003
On Wed, 30 Jul 2003 12:46:43 -0400, Danny Castonguay
<castong at mathstat.concordia.ca> wrote:
Hi!
> Clearly, "listB = listA"
>creates the problem. listB and listA become two pointers to the same
>object.
Exactly.
> How then, do I duplicate the two objects; ie make a copy of the
> object that listA is pointing to and have listB point to that object.
Use:
listB = listA[:]
Cheers,
Tino
More information about the Python-list
mailing list