Unpacking tuples/arrays/lists as indices for Numpy Arrays

Posted by ntimes on Stack Overflow See other posts from Stack Overflow or by ntimes
Published on 2010-03-15T03:26:57Z Indexed on 2010/03/15 3:29 UTC
Read the original article Hit count: 267

Filed under:
|

I would love to be able to do

>>> A = numpy.array(((1,2),(3,4)))
>>> idx = (0,0)
>>> A[*idx]

and get

1

however this is not valid syntax. Is there a way of doing this without explicitly writing out

>>> A[idx[0], idx[1]]

?

© Stack Overflow or respective owner

Related posts about python

Related posts about numpy