On 8/14/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > Travis Oliphant wrote: > > However, you can use the ndarray creation function itself to do what you > > want: > > > > a = ndarray(shape=(2,2), dtype=int32, buffer=str, order='F') > > > > This will use the memory of the string as the new array memory. > > > Incidentally, the new array will be read-only. But, you can fix this in > two ways: > > 1) a.flags.writeable = True
Sweet! We now finally have mutable strings for Python: In [2]: astr = '\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00' In [4]: a = N.ndarray(shape=(2,2), dtype=N.int32, buffer=astr, order='F') In [5]: astr Out[5]: '\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00' In [6]: a.flags.writeable = True In [7]: a Out[7]: array([[0, 2], [1, 3]]) In [8]: a[0] = 1 In [9]: astr Out[9]: '\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00' Guido's going to kill you on Thursday, you know ;) f ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion