[Python-Dev] Suggested doc patch for tarfile
Ben North
ben at redfrontdoor.org
Thu Apr 23 14:54:59 CEST 2009
Hi,
The current documentation for tarfile.TarFile.extractfile() does not
mention that the returned 'file-like object' supports close() and also
iteration. The attached patch (against svn trunk) fixes this.
(Background: I was wondering whether I could write
def process_and_close_file(f_in):
with closing(f_in) as f:
# Do stuff with f.
and have it work whether f_in was a true file or the return value of
extractfile(), and thought from the documentation that I couldn't. Of
course, I could have just tried it, but I think fixing the documentation
wouldn't hurt.)
Alternative: enhance the tarfile.ExFileObject class to support use as a
context manager?
Thanks,
Ben.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tarfile.rst.patch
Type: application/octet-stream
Size: 612 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090423/7a16d793/attachment.obj>
More information about the Python-Dev
mailing list