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: 299
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