why not add __enter__ and __exit__ to generator objects? it's really a trivial addition: __enter__ returns self, __exit__ calls close(). it would be used to ensure close() is called when the generator is disposed, instead of doing that manually. typical usage would be:
with mygenerator() as g: g.next() bar = g.send("foo") -tomer
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com