Simple list.append() question

Jeff Massung jmassung at magpiesystems.com
Mon Apr 24 11:31:31 EDT 2000


I'm just learning, but my guess is this:

>>> l=[[]]*3
>>> l
[[], [], []]
>>> l[0].append(3)
>>> l
[[3], [3], [3]]
>>> id(l[0])
8539088
>>> id(l[1])
8539088
>>> id(l[2])
8539088
>>>

The *3 just made three lists pointing to the same place. I don't know how to
get what you want tho ;) someone else can enlighten me, too :).

- Jeff Massung (jmassung at magpiesystems.com)
- Lead software engineer for Magpie Systems (www.magpiesystems.com)
- Bringing smart pigs and data analysis to the pipeline industry!






More information about the Python-list mailing list