copying a list

Steven D. Majewski sdm7g at virginia.edu
Tue Aug 8 11:44:41 EDT 2000


On Tue, 8 Aug 2000, Gert-Jan Hovinga wrote:

> is there an easy way to get a copy of a list instead of a reference?

The slice operator (:) makes a copy containing the sliced (selected)
elements of the list. You can select the entire list with:  a[:] 
which gives you a copy of a. 

-- Steve M.





More information about the Python-list mailing list