copying a list

Gert-Jan Hovinga lance_99_99 at yahoo.com
Tue Aug 8 11:29:24 EDT 2000


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

for example, the following code prints [[1]] :

a = [1, 2]
b = []
b.append(a)
a.pop()
print b

but i want it to print [[1, 2]]

any easy solutions? or do i have to write a copy function myself?

--lance





More information about the Python-list mailing list