Ian Bicking wrote:
Using a one-element list is kind of annoying, because it isn't clear out
of context that it's just a way of creating shared state. But it's
okay, work right now, and provides the exact same functionality.
Uh, isn't shared state what classes were invented for?
Py> class mygen(object):
... def __init__(self, data):
... self.data = data
... def __iter__(self):
... while 1:
... print self.data
... yield None
...
Py> g = mygen(0)
Py> giter = iter(g)
Py> giter.next()
0
Py> g.data = 1
Py> giter.next()
1
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list