[Python-Dev] generators and with
tomerfiliba at gmail.com
Sun May 13 16:56:15 CEST 2007
why not add __enter__ and __exit__ to generator objects?
it's really a trivial addition: __enter__ returns self, __exit__ calls
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:
bar = g.send("foo")
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev