Augmented generators?
Raymond Hettinger
python at rcn.com
Tue Jan 10 14:11:20 EST 2006
Andrew Koenig wrote:
> Can anyone think of an easy technique for creating an object that acts like
> a generator but has additional methods?
Perhaps the enable_attributes() recipe will help:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/164044
The recipe imbues generators with classlike attribute reads and writes.
It shouldn't be hard to adapt the technique for attaching methods.
Raymond
More information about the Python-list
mailing list