문제

I don't remember whether this is Python or numpy specific. I once found an index iterator that is not in the main introduction and however I try to look for it, I couldn't find it anymore. This is what it gave me:

>>> foo = ones((1,2,3))

>>> for i in foo.getThisMagicIteratorIndexThiny():
>>>     print i
(0,0,0)
(0,0,1)
(0,0,2)
(0,1,0)

And, foo[i] would return the corresponding value. Does anyone know which iterator I am talking about?

도움이 되었습니까?

해결책

As per flebool's comment the solution is to use for idx in np.ndindex(foo.shape):

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top