From: Francesc A. <fa...@ca...> - 2006-09-29 16:44:17
|
A Divendres 29 Setembre 2006 18:12, Tim Hochberg va escriure: > It's not that the it's being built from ndarray, it's that the buffer > that you are passing it is read only. In fact, I'd argue that allowing > the writeable flag to be set to True in this case is actually a bug. > > Consider this slightly modified example: > >>> a =3D "12345"*4 > >>> f4=3Dnumpy.ndarray(buffer=3Da, dtype=3D"f4", shape=3D3) > >>> f4[2] =3D 99 > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > RuntimeError: array is not writeable > > >>> f4.flags.writeable =3D True > >>> a > > '12345123451234512345' > > >>> f4.flags.writeable =3D True > >>> f4[2] =3D 99 > >>> a > > '12345123\x00\x00\xc6B34512345' > > The original, *immutable* string has been mutated. This could get you > into real trouble in certain situations. I see. Thanks for the explanation. =2D-=20 >0,0< Francesc Altet =A0 =A0 http://www.carabos.com/ V V C=E1rabos Coop. V. =A0=A0Enjoy Data "-" |