from __future__ import generators def generador1(max = 1024): x = 1 while x <= max: yield x x = x * 2 g1 = generador1() for i in g1: print i