x = y
Bernie
bernie at pacific.net.hk
Tue Feb 6 16:58:26 EST 2001
"José Luis Gallego" wrote:
> Hi all,
>
> I want to create a list x from a list y:
>
> y = [[1,2,3],[4,5,6]]
> x = y
>
> How do I change individual elements of x without changing y?
>
I think you need the copy module.
import copy
y = [[1,2,3],[4,5,6]]
x = copy.copy(y)
This will do for a shadow copy. See documentation for the copy module
in Python
Library Reference for furthur details
> Thanks in advance,
>
> Jose Luis
Bernie
More information about the Python-list
mailing list