Jens Rantil wrote: > > Thanks Sturla. However numpy.uint8 seem to be lacking attributes 'str' > and 'descr'. I'm using installed Ubuntu package 1:1.1.1-1. Is it too old > or is the code broken? Oops, my fault :)
def fromaddress(address, nbytes, dtype=float): class Dummy(object): pass d = Dummy() bytetype = numpy.dtype(numpy.uint8) d.__array_interface__ = { 'data' : (address, False), 'typestr' : bytetype.str, 'descr' : bytetype.descr, 'shape' : (nbytes,), 'strides' : None, 'version' : 3 } return numpy.asarray(d).view(dtype=dtype) You will have to make sure the address is an integer. > Also, could you elaborate why dtype=float would work better? Because there is no such thing as a double type in Python? Sturla Molden _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion