[Python-Dev] generators and with (original) (raw)
tomer filiba tomerfiliba at gmail.com
Sun May 13 16:56:15 CEST 2007
- Previous message: [Python-Dev] Summary of Tracker Issues
- Next message: [Python-Dev] generators and with
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20070513/df02d804/attachment.html
- Previous message: [Python-Dev] Summary of Tracker Issues
- Next message: [Python-Dev] generators and with
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]