0
Python ???????
For shallow copy which one is the ideal method. lis=[1,2,3,4] lis2= lis.copy() OR import copy lis2 = copy.copy(lis)
3 Respostas
+ 2
Python 2 will expire soon anyway.
Nonetheless, there are other simple ways to make a shallow copy:
lis2 = list(lis1)
lis2 = lis1[:]
lis2 = [n for n in lis1]
+ 1
When you can do something just using what the builtin types easily provide, it seems sensible to use just these.
0
HonFu lis.copy() works in python3 only