[Tutor] Copying lists

Brian Wisti brianwisti at yahoo.com
Mon May 9 05:05:10 CEST 2005


--- jfouhy at paradise.net.nz wrote:
> For making a shallow copy of a list, which syntax is preferable:
> 
> >>> lst2 = lst1[:]
> 
> or
> 
> >>> lst2 = list(lst1)
> 
> ?

I guess my personal preference would be for the first option. I'm not
sure if there is an officially blessed way to go about it, though. Try
one, and if somebody starts shouting at you, switch to the other ;-)

Kind Regards,

Brian Wisti
http://coolnamehere.com/


More information about the Tutor mailing list