Duplicating a variable
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Jan 24 18:50:52 CET 2008
hnessenospam at yahoo.com a écrit :
> I have run into a bit of a subtle problem. How do I go about
> duplicating a variable (particularly a list of lists) in python.
using the deepcopy function of the copy module.
> was surprised when simple assignment didn't work. For example, let y =
>>>> x = y
>>>> x = 5
Python only uses object references. It never copy anything unless
explicitely asked for.
More information about the Python-list