`for-in` loops, https://docs.python.org/3/whatsnew/3.3.html#pep-380-syntax-for-delegating-to-a-subgenerator[`yield from`] and iterable unpacking only work with https://docs.python.org/3/glossary.html#term-iterable[iterable objects]. In order to be iterable, an object should have either an ``++__iter__++`` method or a ``++__getitem__++`` method implementing the https://docs.python.org/3/glossary.html#term-sequence[Sequence] protocol.
These implementations make it possible to execute the following program:
[source,python]
----
my_iterator = IterExample()
for i in my_iterator:
print(i) # Prints 1,2,3,4
my_iterator = GetItemExample()
for i in my_iterator:
print(i) # Prints 1,2,3,4
----
Note also that iterating over an https://docs.python.org/3/glossary.html#term-asynchronous-iterable[asynchronous iterable], i.e. an object having the ``++__aiter__++`` method, requires the use of https://docs.python.org/3/reference/compound_stmts.html#the-async-for-statement[``++async for ... in++``] instead of ``++for ... in++``. Failing to provide the `async` keyword will result in a `TypeError` stating the object is not iterable.
== How to fix it
Make sure your object is an iterable when using it in `for-in` loops,`yield from` and unpacking statements, by implementing ``++__iter__++`` or ``++__getitem__++``. To iterate over an asynchronous iterable, make sure to use the `async` keyword, i.e `async for ... in`.