grocery_stocker wrote: >>>> while True: > ... i = gen.next() > ... print i > ... > 0 > 1 > 4
python's magic isn't as magic as you hope. roughly speaking, it only does the necessary rewriting (writing the equivalent code with next etc etc) when you define a function or a method that contains "yield". the above doesn't, so it's not rewritten and there's no magic. more exactly: http://docs.python.org/reference/datamodel.html#index-1747 andrew -- http://mail.python.org/mailman/listinfo/python-list