[Tutor] Copying a list?
Zak Arntson
zak at harlekin-maus.com
Wed Aug 27 15:25:00 EDT 2003
I feel pretty silly asking this, but is there a way to quickly copy a
list? I'd love to be able to type:
###
>>> a = [1,2,3]
>>> b = a
###
But that's a pass-by-reference. The quickest thing that comes to mind is:
###
>>> a = [1,2,3]
>>> b = [i for i in a]
###
Which is okay, but not as obvious as, say:
###
>>> a = [1,2,3]
>>> b= a.__copy__()
###
or something. Am I forgetting something?
---
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em
More information about the Tutor
mailing list