[Numpy-discussion] Should the fields in void scalars be available?

Travis E. Oliphant oliphant at enthought.com
Fri Jun 27 18:13:44 EDT 2008


Robert Kern wrote:
>
> The only inconsistency I can see here is that x.item() gives a tuple
> rather than a scalar record. A scalar record does have field access,
> but the tuple doesn't.
>
> In [28]: x.item()['a']
>   
.item() always returns a standard Python type.  So, this is expected 
behavior.

If you want to index a 0-d array to get the array scalar do

x[()] or x[...]

-Travis




More information about the NumPy-Discussion mailing list