[clug-progsig] python lists

Dave Lee dave at cherryville.org
Sun Sep 12 17:46:01 PDT 2004


Goran wrote:
> My question is: how to make 'copy' of list which will not be affected when 
> change the original list?

list2 = list1[:]
# or
list2 = list(list1)

these are referred to as shallow copies, if you don't know what that means you should look it up.  you can find out more here: http://www.python.org/doc/current/lib/module-copy.html

Dave




More information about the clug-progsig mailing list