copy list, which way is best? /style
Andreas Kuntzagk
andreas.kuntzagk at mdc-berlin.de
Wed Jul 9 07:07:39 EDT 2003
Hi,
There are three ways to (shallow)copy a list l I'm aware of:
>>> l2=list(l)
>>> l2=l[:]
>>> l2.copy.copy(l)
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?
Andreas
More information about the Python-list
mailing list