Newbie, problem array
Kalle Svensson
kalle at gnupung.net
Wed Apr 11 11:24:34 EDT 2001
Sez Roland Oviol:
> >>> d1=[[0,0]]
> >>> d2=d1[:]
> >>> d2[0][0] = 3
> >>> d2
> [[3, 0]]
> >>> d1
> [[3, 0]]
For nested lists, like [[0,0]], use deepcopy in the copy module:
>>> import copy
>>> d1 = [[0,0]]
>>> d2 = copy.deepcopy()
>>> d2[0][0] = 3
>>> d2
[[3, 0]]
>>> d1
[[0, 0]]
>>>
Peace,
Kalle
--
Email: kalle at gnupung.net | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
[ Not signed due to lossage. Blame Microsoft Outlook Express. ]
More information about the Python-list
mailing list