How does the built-in function iter() convert a Python list to an iterator?

Viewed 3853

I have read my materials, which tell that a Python iterator must have both __iter__ and __next__ methods, but an iterable just needs __iter__.

I check a list and find it has no __next__ method. When using iter() on it, it will become an iterator. Does this mean that iter() will add a __next__ method to a list to convert it to an iterator?

If yes, how does this happen?

1 Answers
Related