0

In general, what does an object need to have in order to be an iterator? Programmatically, what does class need to have in Python to be used as an iterator?

0

1 Answer 1

5

You need to implement __iter__(), which should return an iterator object. The iterator object should implement next(), which will raise a StopIteration exception on iteration completion.

http://docs.python.org/2/library/stdtypes.html#iterator-types

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.