[Tutor] Copying list contents
alan.gauld@bt.com
alan.gauld@bt.com
Mon, 29 Jul 2002 11:11:12 +0100
> Python treates the lists like objects
All python variables are references, regardless of the
object to which they point.
> def copylist(a):
return a[:] # list slicing the whole list creates a copy.
The map and filter functions can also be used to copy lists
with various element modifications applied en route.
And zip() can be used to join lists together.
> but I'm working with lists of lists of lists...
There is also a deepcopy module for copying nested lists.
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld