I have a very simple example of for loop in Python:
for el in [1, 2, 3, 4]:
print(el)
I know that in for loop interpretator calls __iter__
from list to get list iterator.
I have some questions:
- Are all elements of this list stored in memory before the beginning for loop?
- Please explain how the for loop works in this case. What is the deep mechanism of for loop?