Message258233
| Author |
martin.panter |
| Recipients |
benhoyt, gvanrossum, martin.panter, serhiy.storchaka, vstinner |
| Date |
2016年01月14日.22:14:15 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1452809656.09.0.116484964328.issue25994@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I definitely support adding a close() method, and a ResourceWarning if the iterator is not exhausted when it is deallocated. Adding context manager support is probably worthwhile as well, though there is one disadvantage: it would be hard to implement scandir() as a plain generator, because generators don’t support the context manager protocol. But C Python’s implementation is in C, and even in native Python you could implement it as a custom iterator class.
I suggest using this issue for adding the new API(s), presumably to 3.6 only, and Issue 26111 for adding a warning to the existing 3.5 documentation. |
|