2

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?

2
  • 2
    You can use for idx in np.ndindex(foo.shape): Commented May 15, 2014 at 9:11
  • Perfect. If you add an answer, we can close this. Commented May 15, 2014 at 10:46

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.