Message187431
| Author |
ncoghlan |
| Recipients |
Anssi.Kääriäinen, amaury.forgeotdarc, benjamin.peterson, docs@python, isoschiz, ncoghlan, pconnell, pitrou, vstinner |
| Date |
2013年04月20日.14:55:33 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1366469734.15.0.287079498013.issue17468@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
We can't make ordinary generators innately context managers, as it makes the error too hard to detect when you accidentally leave out @contextmanager when using a generator to write a custom one.
You can already use contextlib.closing to forcibly close them when appropriate, so providing a decorator to implicitly map __exit__ to close wouldn't really save much. |
|