[Numpy-discussion] Accessing rank-0 array value?

Francesc Alted falted at pytables.org
Mon Jun 7 02:18:04 EDT 2004


Hi,

Perhaps this is a stupid question, but I did not found any easy way to get
the python object value from a rank-0 numarray array. That is:

>>> from numarray import *
>>> b=array(2)
>>> b
array(2)
>>> b[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IndexError: Too many indices

In C, that seem to be possible provided you use the call:
PyObject* PyArray_Return(PyArrayObject *apr)

Is there any way to do that in python?

Thanks,

-- 
Francesc Alted





More information about the NumPy-Discussion mailing list