Numpy problem: Arrays in a list of dictionaries
ZMY
zhonghua.m.yang at gmail.com
Tue Apr 17 15:23:30 EDT 2007
I am new to Numpy/Pylab, and I am trying to construct a list of
dictionaries with arrays as the items, for example:
>>> dict = {1: array([2, 3, 4]), 2: ''}
>>> list1 = []
>>> for i in range(3): list1.append(dict.copy())
...
>>> list1
[{1: array([2, 3, 4]), 2: ''}, {1: array([2, 3, 4]), 2: ''}, {1:
array([2, 3, 4]), 2: ''}]
>>> list1[0][1][1]=100
>>> list1
[{1: array([ 2, 100, 4]), 2: ''}, {1: array([ 2, 100, 4]), 2:
''}, {1: array([ 2, 100, 4]), 2: ''}]
>>> list1[0][2]='Jack'
>>> list1
[{1: array([ 2, 100, 4]), 2: 'Jack'}, {1: array([ 2, 100, 4]),
2: ''}, {1: array([ 2, 100, 4]), 2: ''}]
So the strings can be assigned seperately but arrays can not. What is
the problem here?
I am using python2.4+Numpy1.0.1 on Fedora
Thanks a lot in advance.
- ZMY
More information about the Python-list
mailing list