Why don't you use a class ?
class MyGen(object):
def __iter__(self):
for i in range(2):
yield "I know who I am %s" % self
gen_obj = MyGen()
for x in gen_obj:
print x
For language lawyers: strictly speaking gen_obj is not a generator
object (since it is
restartable) but it may work for you anyway.
Michele Simionato
--
http://mail.python.org/mailman/listinfo/python-list
