Expressões geradoras Python
>>> iterator = ('Hello' for i in range(3))
>>> for x in iterator:
... print(x)
'Hello'
'Hello'
'Hello'
Magnificent Mole
>>> iterator = ('Hello' for i in range(3))
>>> for x in iterator:
... print(x)
'Hello'
'Hello'
'Hello'
def generator():
for item in collection:
yield expression
>>> genexpr = ('Hello' for i in range(3))
>>> list(genexpr)
['Hello', 'Hello', 'Hello']
>>> for x in even_squares:
... print(x)
0
4
16
36
64