copy list, which way is best? /style
ajw126 at york.ac.uk
Wed Jul 9 14:28:38 CEST 2003
Andreas Kuntzagk wrote:
> There are three ways to (shallow)copy a list l I'm aware of:
> Are there any differences? Are there more (reasonable) ways?
> I think the first is the most pythonic, second looks more like this other
> p-language and third requires an import, so I would prefer the first.
> Do you agree?
The way I'd do it is
from copy import copy
l2 = copy(l1)
from copy import deepcopy
l2 = deepcopy(l1)
I don't know what the difference is, if any, but I think this way is more
Study + Hard Work + Loud Profanity = Good Code
More information about the Python-list