Fernando Perez wrote: > 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 ;) > Don't tell him ;-)
But, if he had provided a suitable bytes type already (that was pickleable) we wouldn't need to do this :-) Notice it's not writeable by default, so at least you have to "know what you are doing" to shoot yourself in the foot. -Travis ------------------------------------------------------------------------- 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