I'm a little confused over the difference between iterators and iterables. I've done a lot of reading and have got this much:
Iterator: An object that has __next__
in it’s class. You can call next() on it. All iterators are iterable.
Iterable: An object that defines __iter__
or __getitem__
in it's class. Something is iterable if it can build an iterator using iter(). Not all iterables are iterators.
Is some_dict.items()
an iterator? I know that some_dict.iteritems()
would be in Python2 right?
I'm just checking because a course I'm doing says it is and I'm pretty sure it's just an iterable (not an iterator).
Thanks for your help :)