def increment():
i = 0
while True:
yield i
i += 1
for j in increment():
print i
if (j > 10) : break
===== 斐波那契无限列表 =====
def fibonacci():
i = j = 1
while True:
result, i, j = i, j, i + j
yield result
for k in fibonacci():
print k
if (k > 100) : break
===== 参考 =====
* http://developer-in-test.blogspot.com/2009/10/infinite-lists-in-python.html