[Numpy-discussion] np.fromstring and Python 3

Thomas Robitaille thomas.robitaille@gmail....
Sun Jul 25 09:17:53 CDT 2010


The following example illustrates a problem I'm encountering a problem with the np.fromstring function in Python 3:

Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> string = "".join(chr(i) for i in range(256))
>>> a = np.fromstring(string, dtype=np.int8)
>>> print(len(string))
>>> print(len(a))

The array 'a' should have the same size as 'string' since I'm using a 1-byte datatype. Is this a bug, or do I need to change the way I use this function in Python 3?

I am using Numpy r8523



More information about the NumPy-Discussion mailing list