✨
I'm Kevin
@kevteg
@keeevinh
Any object that implements the next
method, that is, an object that you can iterate over
A "lazy" iterator, that is, the value is calculated during the iteration
import time
def fibonacci():
'''Good old fibonacci'''
a, b = 0, 1
while True:
yield b
# Sleep to be able to see the numbers generation
time.sleep(1)
a, b = b, a+b
cool_iterator = (n for n in range(1000000000))
def coroutine():
# dumb coroutine example
x = 0
while True:
x = (yield x) + x
❤️ 🐍
@kevteg
@keeevinh