What can be iterable
suggest changeIterable can be anything from which items are received one by one. Built-in collections can be iterated again. A generator is forward-only and is spent after one pass. Built-in Python collections are iterable:
[1, 2, 3] # list, iterate over items
(1, 2, 3) # tuple
{1, 2, 3} # set
{1: 2, 3: 4} # dict, iterate over keys
A generator function returns a generator iterator, which is iterable:
def foo(): # the function itself is not an iterator
yield 1
res = foo() # res is a generator iterator
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents