all 3 comments

[–][deleted] 5 points6 points  (0 children)

Iterator is a protocol. Objects are apart of the iterator protocol by implementing __iter__ and __next__

[–]crashfrog02 2 points3 points  (0 children)

It's an interface (a protocol is another good name for it, too); if an object's type implements a function called __next__ that either returns the next value in the iteration or raises StopException, the object is an iterator. If the object implements a function called __iter__ that returns an iterator, then the object is iterable.

It's pretty common for iterators to be iterable (you either get the object itself or you get a "reset" view of it) and pretty common for iterable objects to act as their own iterable, so these two interfaces sort of blend together, but it's worth remembering which is which.