On Thu, 19 Apr 2007 20:00:31 -0700, Alex Martelli wrote: > class sane(object): > def __init__(self, sentence='four scores and twenty years ago'): > def agenerator(): > for word in sentence.split(): yield word > self._thegen = agenerator() > def __iter__(self): return self > def next(self): return self._thegen.next()
Nice technique! I always forget about nesting functions like that. I should use it more often. -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list