]> granicus.if.org Git - python/commitdiff
#21146: give a more efficient recipe in gzip docs
authorAndrew Kuchling <amk@amk.ca>
Tue, 14 Apr 2015 15:44:40 +0000 (11:44 -0400)
committerAndrew Kuchling <amk@amk.ca>
Tue, 14 Apr 2015 15:44:40 +0000 (11:44 -0400)
Doc/library/gzip.rst

index a8e77049d370517335003840b6432c2fb0e2f85f..04c41d585c8e0c8b5783a818dd54d04306dc8194 100644 (file)
@@ -189,9 +189,10 @@ Example of how to create a compressed GZIP file::
 Example of how to GZIP compress an existing file::
 
    import gzip
+   import shutil
    with open('/home/joe/file.txt', 'rb') as f_in:
        with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:
-           f_out.writelines(f_in)
+           shutil.copyfileobj(f_in, f_out)
 
 Example of how to GZIP compress a binary string::